Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/mobile-native-qualification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
paths:
- 'scripts/apply-keyring-ledger.cjs'
- 'scripts/keyring-ledger-2.1.7.json'
- 'scripts/apply-walletconnect-terminal.cjs'
- 'scripts/walletconnect-terminal.json'
- 'apps/mobile/src/**'
- 'apps/mobile/modules/**'
- 'apps/mobile/qualification/**'
Expand Down Expand Up @@ -112,6 +114,7 @@ jobs:
cache-dependency-path: apps/mobile/package-lock.json
- run: npm ci --ignore-scripts
- run: node ../../scripts/apply-keyring-ledger.cjs
- run: node ../../scripts/apply-walletconnect-terminal.cjs
- run: node --import ./scripts/register-shared-test-dependencies.mjs --test qualification/*.test.cjs
- run: xcodebuild -version
- name: Run Swift public snapshot loopback
Expand Down Expand Up @@ -204,6 +207,7 @@ jobs:
echo "$PALI_SDK_ROOT/emulator" >> "$GITHUB_PATH"
- run: npm ci --ignore-scripts
- run: node ../../scripts/apply-keyring-ledger.cjs
- run: node ../../scripts/apply-walletconnect-terminal.cjs
- run: node --import ./scripts/register-shared-test-dependencies.mjs --test qualification/*.test.cjs
- name: Install pinned native toolchain
run: sdkmanager 'ndk;27.1.12297006' 'platforms;android-37.0' 'build-tools;37.0.0'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'scripts/apply-walletconnect-terminal.cjs'
- 'scripts/walletconnect-terminal.json'
- 'apps/mobile/**'
- 'scripts/apply-keyring-ledger.cjs'
- 'scripts/keyring-ledger-2.1.7.json'
Expand Down Expand Up @@ -88,6 +90,7 @@ jobs:
cache-dependency-path: apps/mobile/package-lock.json
- run: npm ci --ignore-scripts
- run: node ../../scripts/apply-keyring-ledger.cjs
- run: node ../../scripts/apply-walletconnect-terminal.cjs
- name: Reject moderate and higher dependency advisories
run: npm audit --audit-level=moderate
- run: npm run lint
Expand Down Expand Up @@ -133,6 +136,7 @@ jobs:
cache-dependency-path: apps/mobile/package-lock.json
- run: npm ci --ignore-scripts
- run: node ../../scripts/apply-keyring-ledger.cjs
- run: node ../../scripts/apply-walletconnect-terminal.cjs
- name: Build preview
if: matrix.suite == 'preview'
run: npm run build:web
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/package-lock.json

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

5 changes: 3 additions & 2 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:faucet-ui": "playwright test --config playwright.faucet.config.ts",
"test:recovery-ui": "node scripts/build-native-recovery-ui.cjs && playwright test --config playwright.recovery.config.ts",
"lint": "eslint . --max-warnings 0",
"postinstall": "node ../../scripts/apply-keyring-ledger.cjs"
"postinstall": "node ../../scripts/apply-keyring-ledger.cjs && node ../../scripts/apply-walletconnect-terminal.cjs"
},
"dependencies": {
"@craftzdog/react-native-buffer": "6.1.2",
Expand Down Expand Up @@ -112,5 +112,6 @@
"paliKeyringPatch": {
"sourceCommit": "c68e7f7ca8dd13789a7428a8ec35d3b84a46f2f8",
"manifestSha256": "28153063e5d18b4348191b7f2293cd58d9e6bdc585a7e2481975ad6e9d13d2ac"
}
},
"paliWalletConnectPatch": "core.9a6890ed312e22696246d1c971674816158bc289.utils.7e48b0453db3f3c7f2d417ef3823fc5c218f21bf.sha256.03ce9132174333bdb653e3b0d8da3e87fad27532fdc0c2f6ab1b0c528f1b0180"
}
12 changes: 12 additions & 0 deletions apps/mobile/qualification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,15 @@ Strict report fields contain only the imported account identity, three chain IDs
For an official SDK, configuration matches the installed package name and version to the exact manifest pin. A local Speed Up review archive must also match its manifest path, npm lock version and SHA-512 integrity. Configuration compares the installed package files byte for byte with the archive and adds its SHA-256 to the SDK identity embedded in the fixture. The loaded SDK must match the embedded package version, and the host validates the reported identity against the current checkout.

The local iOS runner selects the newest available standard iOS runtime and an installed iPhone device type. PALI_IOS_SIMULATOR_RUNTIME and PALI_IOS_SIMULATOR_DEVICE_TYPE can select exact installed identities; an unavailable explicit selection fails instead of falling back. The hosted workflow intentionally pins iOS26.5, while a local27.2 run binds its refusal report to27.2. Simulator refusal still proves no custody. All Node qualification commands use the existing shared-source dependency resolver so the mobile-only npm installation is authoritative.

### Reviewed WalletConnect lifecycle candidate

The temporary WalletConnect patch uses the public disposal APIs from Core PR 7391 at `9a6890ed312e22696246d1c971674816158bc289` and Utils PR 283 at `7e48b0453db3f3c7f2d417ef3823fc5c218f21bf`. The installed package versions remain 2.26.0 and the corresponding JSON-RPC versions. The candidate identity includes both source revisions and the artifact-manifest hash. Remove the patch when adopting the official releases containing these changes.

The artifacts were rebuilt with TypeScript 5.9.3, Rollup 4.60.1 and rollup-plugin-esbuild 6.2.1 from the Core build toolchain. The Utils build used a Node 26 configuration wrapper for its JSON import and plugin default export, and disabled its removed `suppressImplicitAnyIndexErrors` compiler option. The reviewed runtime sources were unchanged by those build adjustments. Each original package archive was checked against its npm lock integrity before calculating the replacement hashes.

`npm ci --ignore-scripts` must be followed by `node ../../scripts/apply-walletconnect-terminal.cjs` from `apps/mobile`. The patch checks every affected file against its original npm bytes or its reviewed replacement before writing. It covers the CJS, ESM and declaration entry points used by Pali. It excludes CDN UMD bundles.

The existing native HTTP qualification lane also writes a separate `pali-native-walletconnect-<token>.json` sidecar for this candidate. It exercises an actual loopback WebSocket through the production adapter, closes an established connection, cancels an unfinished handshake, and checks that both public SDK owners are retired. The host independently checks socket closure and a quiet interval. The sidecar is required and matched to the build, launch, session and candidate identity before the host accepts that lane.

Node protocol tests exercise the same fixture and adapter. Android and iOS execution of this added lane remains a release gate until evidence is recorded against the exact candidate head.
15 changes: 13 additions & 2 deletions apps/mobile/qualification/http-companion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { readFileSync } = require('node:fs');
const path = require('node:path');
const { assertHttpReport, httpDiagnosticCase } = require('./http-contract.ts');
const { assertPostReport, postDiagnosticCase } = require('./post-contract.ts');
const { assertWalletConnectAudit, assertWalletConnectReport } = require('./walletconnect-contract.ts');
const { assertPostAudit, partialPostAudit } = require('./post-server.cjs');
const { isAmbiguousCommandFailure } = require('./command-runner.cjs');
const { ROUTES, HELD_ROUTES } = require('./http-server.cjs');
Expand Down Expand Up @@ -41,7 +42,7 @@ function partialAudit(value, token, port) {
return { counts: { ...value.counts }, invalid: value.invalid, closed: { ...value.closed } };
}

async function startHttpCompanion({ platform, sourceRevision, run, spawn = fork }) {
async function startHttpCompanion({ platform, sourceRevision, run, spawn = fork, walletConnectIdentity }) {
if (!['ios', 'android'].includes(platform) || !/^[0-9a-f]{40}$/.test(sourceRevision || ''))
throw Error('HTTP_FIXTURE_SOURCE_REQUIRED');
const lockfileSha256 = createHash('sha256').update(readFileSync(path.join(__dirname, '../package-lock.json'))).digest('hex');
Expand Down Expand Up @@ -149,14 +150,24 @@ async function startHttpCompanion({ platform, sourceRevision, run, spawn = fork
const postReport = JSON.parse(postText);
assertPostReport(postReport, active);
if (postReport.sessionId !== sessionId) throw Error('POST_FIXTURE_SESSION_MISMATCH');
let walletConnect;
if (walletConnectIdentity) {
const text = read(`pali-native-walletconnect-${active.token}.json`);
if (typeof text !== 'string' || Buffer.byteLength(text) > 4096) throw Error('WALLETCONNECT_NATIVE_REPORT_INVALID');
const report = JSON.parse(text);
assertWalletConnectReport(report, { ...active, sessionId, candidateIdentity: walletConnectIdentity });
const audit = await rpc('inspectWalletConnect', active.token);
assertWalletConnectAudit(audit);
walletConnect = { report, audit };
}
failedCase = 'host-verification';
const snapshot = await rpc('snapshotAll', active.token);
if (!snapshot || Object.keys(snapshot).sort().join(',') !== 'get,post') throw Error('HTTP_FIXTURE_AUDIT_FAILED');
const audit = finalAudit = snapshot.get;
finalPostAudit = snapshot.post;
assertAudit(audit, active.token, port);
assertPostAudit(finalPostAudit, active.token, port);
records.push({ nativeHttpQualified: true, report, audit,
records.push({ nativeHttpQualified: true, report, audit, ...(walletConnect ? { walletConnect } : {}),
post: { nativePostQualified: true, report: postReport, audit: finalPostAudit } });
active = undefined;
return records.at(-1);
Expand Down
11 changes: 9 additions & 2 deletions apps/mobile/qualification/http-server.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const http = require('node:http');
const { walletConnectFixture, emptyWalletConnectAudit } = require('./walletconnect-server.cjs');
const { Buffer } = require('node:buffer');
const { timingSafeEqual } = require('node:crypto');
const { QUOTE_EARLY_REJECTIONS, STALLED_QUOTE_ROUTE, PUBLIC_SNAPSHOT_FIXTURE_PATH,
Expand All @@ -24,6 +25,10 @@ async function createHttpFixture() {
if (active) active.invalid++;
response.writeHead(400); response.end(); return;
}
if (request.method === 'GET' && request.url === `/${active.token}/wc-status?q=exact`) {
response.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
response.end(JSON.stringify(active.walletConnect)); return;
}
// The production downloader appends a fixed path, so this public fixture
// is tied to the active launch's dedicated port instead of a URL token.
if (request.url === PUBLIC_SNAPSHOT_FIXTURE_PATH) {
Expand Down Expand Up @@ -127,6 +132,7 @@ async function createHttpFixture() {
}
ok();
});
const walletConnect = walletConnectFixture(server, () => active);
server.maxHeadersCount = 24;
server.maxConnections = 12;
server.headersTimeout = 5000;
Expand All @@ -139,7 +145,7 @@ async function createHttpFixture() {
begin(token) {
if (active || typeof token !== 'string' || !/^[0-9a-f]{32}$/.test(token)) throw Error('HTTP_FIXTURE_BEGIN_INVALID');
active = { token, counts: Object.fromEntries(ROUTES.map((route) => [route, 0])), invalid: 0,
closed: Object.fromEntries(HELD_ROUTES.map((route) => [route, false])), waiters: new Set(), post: createPostState(token, port) };
closed: Object.fromEntries(HELD_ROUTES.map((route) => [route, false])), waiters: new Set(), walletConnect: emptyWalletConnectAudit(), post: createPostState(token, port) };
},
inspect(token) {
if (!active || !equal(token, active.token)) throw Error('HTTP_FIXTURE_TOKEN_INVALID');
Expand All @@ -150,6 +156,7 @@ async function createHttpFixture() {
active = undefined;
return result;
},
inspectWalletConnect(token) { this.inspect(token); return walletConnect.inspect(); },
inspectAll(token) { const get = this.inspect(token); return { get, post: postSnapshot(active.post) }; },
snapshotAll(token) { const result = this.inspectAll(token); active = undefined; return result; },
async close() { for (const socket of sockets) socket.destroy(); await new Promise((resolve) => server.close(resolve)); },
Expand All @@ -170,7 +177,7 @@ if (require.main === module) {
try {
if (!message || !Number.isSafeInteger(message.id)) throw Error('HTTP_FIXTURE_MESSAGE_INVALID');
if (message.kind === 'begin') { fixture.begin(message.token); process.send({ id: message.id, ok: true }); }
else if (['snapshot', 'inspect', 'snapshotAll', 'inspectAll'].includes(message.kind)) process.send({ id: message.id, ok: true, value: fixture[message.kind](message.token) });
else if (['snapshot', 'inspect', 'snapshotAll', 'inspectAll', 'inspectWalletConnect'].includes(message.kind)) process.send({ id: message.id, ok: true, value: fixture[message.kind](message.token) });
else if (message.kind === 'close') void stop();
else throw Error('HTTP_FIXTURE_MESSAGE_INVALID');
} catch { process.send({ id: message?.id, ok: false }); }
Expand Down
22 changes: 22 additions & 0 deletions apps/mobile/qualification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { captureQualificationCryptoLoad, captureQualificationModuleLoad } from '
import { qualifyNativeHandleContract } from './native-handle-contract.ts';
import { createStorageQualificationDiagnostic } from './storage-diagnostics.ts';
import { httpBuild, type HttpLaunch } from './http-contract.ts';
import { withWalletConnectQualificationScope } from './walletconnect-scope.ts';
import { makePublicPoolFailure, PUBLIC_POOL_FAILURE_FILE, publicPoolBuild, type PublicPoolLaunch } from './public-pool-contract.ts';

import type { NativeCustodyAuthority } from '../src/custody/authority.ts';
Expand Down Expand Up @@ -144,6 +145,7 @@ function QualificationApp() {
};
try {
parameters = await launchParameters();
const NativeWebSocket = globalThis.WebSocket;
globalThis.fetch = (() => {
networkCalls++;
throw Error('QUALIFICATION_NETWORK_FORBIDDEN');
Expand Down Expand Up @@ -342,6 +344,26 @@ function QualificationApp() {
sessionId: Constants.sessionId, networkCalls: () => networkCalls });
await FileSystem.writeAsStringAsync(`${destination}.tmp`, JSON.stringify(evidence));
await FileSystem.moveAsync({ from: `${destination}.tmp`, to: destination });
const candidateIdentity = Constants.expoConfig?.extra?.paliWalletConnectIdentity;
if (candidateIdentity !== undefined) {
if (typeof candidateIdentity !== 'string') throw Error('WALLETCONNECT_NATIVE_BUILD_INVALID');
stage = 'native WalletConnect lifecycle';
const { http: launch, phase, scenario } = parameters;
const connectionEvidence = await withWalletConnectQualificationScope({
crypto: nativeCrypto, WebSocket: NativeWebSocket, launch,
onForbidden() { networkCalls++; throw Error('QUALIFICATION_NETWORK_FORBIDDEN'); },
}, async () => {
const { prepareWalletConnectRuntime } = await import('../src/platform/walletConnectRuntime.native');
await prepareWalletConnectRuntime();
const { qualifyNativeWalletConnect } = await import('./walletconnect-native.ts');
return qualifyNativeWalletConnect({ launch, build,
candidateIdentity, walletFetch, phase, scenario,
platform: Platform.OS as 'ios' | 'android', sessionId: Constants.sessionId });
});
const connectionDestination = `${FileSystem.documentDirectory}pali-native-walletconnect-${parameters.http.token}.json`;
await FileSystem.writeAsStringAsync(`${connectionDestination}.tmp`, JSON.stringify(connectionEvidence));
await FileSystem.moveAsync({ from: `${connectionDestination}.tmp`, to: connectionDestination });
}
stage = 'native POST transport';
const postDestination = `${FileSystem.documentDirectory}pali-native-post-${parameters.http.token}.json`;
const postEvidence = await qualifyNativePost({ launch: parameters.http, build, walletFetch,
Expand Down
10 changes: 9 additions & 1 deletion apps/mobile/qualification/ios-launch-reports.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ async function actualRunner({ created = report(), writeFailure = false, readFail
else if (args[1] === 'launch' && !reportFailure) return { status: null, signal: 'SIGTERM', error: Object.assign(Error('launch timeout'), { code: 'ETIMEDOUT' }) };
return { status: 0, stdout };
} };
if (name === './http-companion.cjs') return { async startHttpCompanion({ platform, sourceRevision }) {
if (name === '../scripts/qualification-sdk.cjs') return {
readWalletConnectSdkIdentity(root) {
assert.equal(root, path.dirname(path.dirname(require.resolve('./run-native.cjs'))));
return 'fixture-walletconnect-identity';
},
};
if (name === './http-companion.cjs') return { async startHttpCompanion({ platform, sourceRevision, walletConnectIdentity }) {
assert.equal(http, true, 'the fixture must never start a real HTTP companion');
assert.equal(walletConnectIdentity, 'fixture-walletconnect-identity');
events.push(['http-start', platform, sourceRevision]);
return {
async begin(phase, scenario) {
Expand Down Expand Up @@ -207,6 +214,7 @@ async function actualRunner({ created = report(), writeFailure = false, readFail
}
return require(name);
}, process, console: { log() {}, error() {} }, setTimeout,
__dirname: path.dirname(require.resolve('./run-native.cjs')),
});
return { events, writes, process, launchError, validationError, reportedError, reportReads: files.reads, closedReports: files.closed };
}
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/qualification/run-native.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async function ios() {
const reports = [];
if (httpEnabled) {
const { startHttpCompanion } = require('./http-companion.cjs');
httpCompanion = await startHttpCompanion({ platform, sourceRevision: process.env.GITHUB_SHA, run });
httpCompanion = await startHttpCompanion({ walletConnectIdentity: require('../scripts/qualification-sdk.cjs').readWalletConnectSdkIdentity(path.join(__dirname, '..')), platform, sourceRevision: process.env.GITHUB_SHA, run });
}
for (const scenario of (simulatorContract ? ['import'] : ['import', 'generate'])) {
const stage = createIosStageRecorder((evidence) => fs.writeFileSync(
Expand Down Expand Up @@ -479,7 +479,7 @@ async function android() {
}
if (httpEnabled) {
const { startHttpCompanion } = require('./http-companion.cjs');
httpCompanion = await startHttpCompanion({ platform, sourceRevision: process.env.GITHUB_SHA, run });
httpCompanion = await startHttpCompanion({ walletConnectIdentity: require('../scripts/qualification-sdk.cjs').readWalletConnectSdkIdentity(path.join(__dirname, '..')), platform, sourceRevision: process.env.GITHUB_SHA, run });
}
const reports = [];
for (const scenario of ['import', 'generate']) {
Expand Down
Loading
Loading