Skip to content
Draft
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
127 changes: 127 additions & 0 deletions .github/scripts/desktop_qa_cloud_smoke.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Disposable Desktop-only smoke. No phone, signer, wallet data or signing action.
import { createCipheriv, randomBytes } from 'node:crypto';
import { createRequire } from 'node:module';
import { execFileSync, spawn } from 'node:child_process';
import { readFileSync, writeFileSync, rmSync, mkdirSync } from 'node:fs';
import { join } from 'node:path';

const requireClient = createRequire(join(process.env.CLIENT_DIR, 'package.json'));
const { io } = requireClient('socket.io-client');
const temp = process.env.RUNNER_TEMP;
const evidence = process.env.EVIDENCE_DIR;
const screenTool = join(temp, 'desktop-qa-screen');
const screenshot = join(temp, 'desktop-private-screen.png');
const report = {
source: 'ef050663d33be51f25fb10310d5a0549b111e273', artifact_id: 11615331902,
tooling_source: process.env.GITHUB_SHA, cloud_run_id: process.env.GITHUB_RUN_ID, runner_architecture: process.arch,
workflow_run_id: 37928395053, state: 'INCOMPLETE', tests: {},
limits: 'Desktop-only disposable cloud smoke; phone pairing, QR camera scanning, reconnect/retry/rotation matrix, physical signer and PSBT round trip NOT RUN. No Continue click, wallet data, signing or broadcast.',
};
let app;
let socket;
let launchError = false;
const pause = ms => new Promise(resolve => setTimeout(resolve, ms));
const record = (name, ok) => { report.tests[name] = ok ? 'PASS' : 'FAIL'; if (!ok) throw new Error(name); };
function inspect() {
report.tool_stage = 'capture_screenshot';
execFileSync('/usr/sbin/screencapture', ['-x', '-t', 'png', screenshot], { stdio: 'ignore' });
report.tool_stage = 'vision_ocr_and_barcode';
const raw = execFileSync(screenTool, [screenshot], { encoding: 'utf8' });
report.tool_stage = 'parse_screen_reader_json';
const view = JSON.parse(raw);
report.tool_stage = 'screen_reader_ready';
report.last_screen_flags = {
get_started: includes(view, 'Get Started'), scan_me: includes(view, 'Scan Me'),
connect_ledger: includes(view, 'Connect Ledger'), server_error: includes(view, 'Server Error'),
qr_payload_count: view.qr.length, qr_64hex_detected: view.qr.some(value => /^[0-9a-f]{64}$/.test(value)),
};
return view;
}
function includes(view, value) { return view.text.some(item => item.text.toLowerCase().includes(value.toLowerCase())); }
async function until(check, label, seconds = 35) {
const end = Date.now() + seconds * 1000;
while (Date.now() < end) {
const view = inspect();
if (check(view)) return view;
await pause(1000);
}
throw new Error(label);
}
function encrypt(key, data) {
const iv = randomBytes(12);
const cipher = createCipheriv('aes-256-gcm', Buffer.from(key, 'hex'), iv);
const encrypted = Buffer.concat([cipher.update(JSON.stringify(data)), cipher.final()]);
return { iv: iv.toString('hex'), encryptedData: encrypted.toString('hex'), authTag: cipher.getAuthTag().toString('hex') };
}
try {
mkdirSync(evidence, { recursive: true });
app = spawn(process.env.APP_BINARY, [], { stdio: 'ignore' });
app.on('error', () => { launchError = true; });
await pause(2000);
record('native_process_launch', !launchError && Boolean(app.pid) && app.exitCode === null);
const welcome = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable');
record('live_channel_welcome_ready', true);
report.native_event_permissions = JSON.parse(execFileSync(screenTool, ['permissions'], { encoding: 'utf8' }));
report.native_activation = JSON.parse(execFileSync(screenTool, ['activate', String(app.pid)], { encoding: 'utf8' }));
await pause(500);
// Compile/query display geometry before taking fresh, settled button bounds.
const display = execFileSync('/usr/bin/swift', ['-e', 'import AppKit; let f=NSScreen.main!.frame; print("\(f.width) \(f.height)")'], {encoding: 'utf8'}).trim().split(' ').map(Number);
function clickGetStarted(view) {
const button = view.text.find(item => item.text.toLowerCase().includes('get started'));
execFileSync(screenTool, ['click', String(button.x * display[0] / view.width), String(button.y * display[1] / view.height)], { stdio: 'ignore' });
}
const settled = await until(view => includes(view, 'Get Started'), 'Welcome/channel readiness unavailable', 10);
clickGetStarted(settled);
await pause(2000);
const afterClick = inspect();
// One bounded first-mouse retry, only while the original welcome remains visible.
if (includes(afterClick, 'Get Started')) {
report.scoped_get_started_retry = true;
clickGetStarted(afterClick);
}
const paired = await until(view => view.qr.some(value => /^[0-9a-f]{64}$/.test(value)), 'QR readiness/click unavailable');
const key = paired.qr.find(value => /^[0-9a-f]{64}$/.test(value));
const { createHash } = await import('node:crypto');
const room = createHash('sha256').update(key).digest('hex');
record('fresh_qr_rendered', true);
socket = io('https://channel.bitcoinkeeper.app/', { transports: ['websocket', 'polling'], reconnection: false, timeout: 15000 });
await new Promise((resolve, reject) => { socket.once('connect', resolve); socket.once('connect_error', () => reject(new Error('Disposable channel sender unavailable'))); });
const send = requestData => socket.emit('JOIN_CHANNEL', { room, network: 'TESTNET', requestData });
const request = { action: 'ADD_DEVICE', signerType: 'LEDGER', accountNumber: 0 };
const altered = encrypt(key, request);
altered.authTag = (altered.authTag[0] === '0' ? '1' : '0') + altered.authTag.slice(1);
send(altered);
await pause(3000);
const rejected = inspect();
record('altered_tag_keeps_qr_without_connect_modal', rejected.qr.includes(key) && !includes(rejected, 'Connect Ledger'));
send({ action: 'ADD_DEVICE', signerType: 'LEDGER' });
await pause(2000);
const plain = inspect();
record('plaintext_keeps_qr_without_connect_modal', plain.qr.includes(key) && !includes(plain, 'Connect Ledger'));
send(encrypt(key, { action: 'ADD_DEVICE' }));
const malformed = await until(view => includes(view, 'Signer type was not provided'), 'Authenticated malformed-action error unavailable', 15);
record('malformed_authenticated_action_shows_error_without_connect_modal', !includes(malformed, 'Connect Ledger'));
send(encrypt(key, request));
const valid = await until(view => includes(view, 'Connect Ledger'), 'Valid encrypted request did not open Connect Ledger', 15);
record('valid_encrypted_add_device_opens_connect_ledger', !includes(valid, 'Signer type was not provided'));
record('native_process_remains_running', app.exitCode === null);
report.state = 'PASSED_DESKTOP_ONLY';
} catch (error) {
// Only fixed labels are emitted; screen contents, QR keys and rooms stay private.
report.state = 'BLOCKED_OR_FAILED';
const label = String(error.message);
const fixedLabels = new Set([
...Object.keys(report.tests),
'Welcome/channel readiness unavailable', 'QR readiness/click unavailable',
'Disposable channel sender unavailable', 'Authenticated malformed-action error unavailable',
'Valid encrypted request did not open Connect Ledger',
]);
report.failure = fixedLabels.has(label) ? label : 'Cloud runner/tool failure; no private UI data preserved';
process.exitCode = 1;
} finally {
socket?.disconnect();
app?.kill('SIGTERM');
rmSync(screenshot, { force: true });
writeFileSync(join(evidence, 'desktop-cloud-smoke.json'), JSON.stringify(report, null, 2) + '\n');
console.log(JSON.stringify(report, null, 2));
}
40 changes: 40 additions & 0 deletions .github/scripts/desktop_qa_screen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import AppKit
import Vision
import CoreGraphics
import ApplicationServices

if CommandLine.arguments.count == 4 && CommandLine.arguments[1] == "click" {
guard let x = Double(CommandLine.arguments[2]), let y = Double(CommandLine.arguments[3]) else { fatalError("Invalid click") }
let point = CGPoint(x: x, y: y)
CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap)
Thread.sleep(forTimeInterval: 0.15)
CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap)
Thread.sleep(forTimeInterval: 0.15)
CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left)?.post(tap: .cghidEventTap)
} else if CommandLine.arguments.count == 3 && CommandLine.arguments[1] == "activate" {
guard let pid = Int32(CommandLine.arguments[2]) else { fatalError("Expected PID") }
let activated = NSRunningApplication(processIdentifier: pid)?.activate(options: [.activateIgnoringOtherApps]) ?? false
FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: ["activated_exact_app_pid": activated]))
} else if CommandLine.arguments.count == 2 && CommandLine.arguments[1] == "permissions" {
let value = ["accessibility_trusted": AXIsProcessTrusted(), "post_events_authorized": CGPreflightPostEventAccess(), "screen_capture_authorized": CGPreflightScreenCaptureAccess()]
FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: value))
} else {
guard CommandLine.arguments.count == 2, let image = NSImage(contentsOfFile: CommandLine.arguments[1]),
let cg = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else { fatalError("Expected screenshot") }
let text = VNRecognizeTextRequest()
text.recognitionLevel = .accurate
// GitHub macOS VMs lack the physical scaler/Metal compute device.
text.usesCPUOnly = true
let barcodes = VNDetectBarcodesRequest()
barcodes.symbologies = [.qr]
barcodes.usesCPUOnly = true
try VNImageRequestHandler(cgImage: cg).perform([text, barcodes])
let words: [[String: Any]] = (text.results ?? []).compactMap { observation in
guard let candidate = observation.topCandidates(1).first else { return nil }
let b = observation.boundingBox
return ["text": candidate.string, "x": b.midX * Double(cg.width), "y": (1 - b.midY) * Double(cg.height)]
}
let values = (barcodes.results ?? []).compactMap { $0.payloadStringValue }
let value: [String: Any] = ["text": words, "qr": values, "width": cg.width, "height": cg.height]
FileHandle.standardOutput.write(try JSONSerialization.data(withJSONObject: value))
}
83 changes: 83 additions & 0 deletions .github/workflows/desktop-qa-cloud-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Desktop disposable cloud acceptance

# Deliberately distinct from release/dev-release: never activates PGP workflow_run.
on:
push:
branches: [codex/r4-desktop-cloud-smoke-20261022]
paths:
- .github/workflows/desktop-qa-cloud-smoke.yml
- .github/scripts/desktop_qa_*

permissions:
contents: read
actions: read

jobs:
existing-qa-smoke:
runs-on: macos-latest
timeout-minutes: 12
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '22'
- name: Fetch immutable existing QA artifact and verify source identity
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
umask 077
mkdir -p "$RUNNER_TEMP/desktop-qa" "$RUNNER_TEMP/desktop-evidence"
gh api repos/KeeperCommunity/keeper-desktop/actions/artifacts/11615331902 > "$RUNNER_TEMP/desktop-qa/artifact.json"
python3 - "$RUNNER_TEMP/desktop-qa/artifact.json" <<'PY'
import json,sys
a=json.load(open(sys.argv[1]))
assert a['id']==11615331902 and not a['expired']
assert a['workflow_run']['id']==37928395053
assert a['workflow_run']['head_sha']=='ef050663d33be51f25fb10310d5a0549b111e273'
PY
gh api repos/KeeperCommunity/keeper-desktop/actions/artifacts/11615331902/zip > "$RUNNER_TEMP/desktop-qa/original.zip"
echo "2a3ca33dd9a539323f41639d98fb36ab8d2cdc670f1b17b20f861b3528eaeea5 $RUNNER_TEMP/desktop-qa/original.zip" | shasum -a 256 -c -
ditto -x -k "$RUNNER_TEMP/desktop-qa/original.zip" "$RUNNER_TEMP/desktop-qa"
echo "9ae0c39eefafd85a9234bf7a599f75e3b13a481ab0ad7f9418eee66990c34a69 $RUNNER_TEMP/desktop-qa/keeper-desktop-r3-qa.zip" | shasum -a 256 -c -
ditto -x -k "$RUNNER_TEMP/desktop-qa/keeper-desktop-r3-qa.zip" "$RUNNER_TEMP/desktop-qa"
python3 - "$RUNNER_TEMP/desktop-qa" "$RUNNER_TEMP/desktop-evidence" <<'PY'
import hashlib,json,plistlib,sys
from pathlib import Path
base=Path(sys.argv[1]); app=base/'Keeper Desktop R3 QA.app'
info=plistlib.loads((app/'Contents/Info.plist').read_bytes())
binary=(app/'Contents/MacOS'/info['CFBundleExecutable']).read_bytes()
assert info['CFBundleIdentifier']=='com.keeper.desktop.r3qa'
assert info['CFBundleShortVersionString']=='0.2.6-qa.1'
assert hashlib.sha256(binary).hexdigest()=='13e252b7a7f339d24e327d8d14d7956946f21b929c037970edffa9e6e90fcb70'
assert b'https://channel.bitcoinkeeper.app/' in binary
assert b'https://keeper-channel.herokuapp.com/' not in binary
evidence=json.loads((base/'desktop-qa-evidence.json').read_text())
assert evidence['source']=='ef050663d33be51f25fb10310d5a0549b111e273'
(Path(sys.argv[2])/'original-artifact-evidence.json').write_text(json.dumps(evidence,indent=2)+'\n')
PY
codesign --verify --deep --strict "$RUNNER_TEMP/desktop-qa/Keeper Desktop R3 QA.app"
uname -m > "$RUNNER_TEMP/desktop-evidence/runner-architecture.txt"
echo 'Artifact bytes, separate QA identity, live endpoint and strict deep code signature PASS.' >> "$GITHUB_STEP_SUMMARY"
- name: Prepare disposable native screen reader and sender
run: |
set -euo pipefail
swiftc .github/scripts/desktop_qa_screen.swift -o "$RUNNER_TEMP/desktop-qa-screen"
mkdir -p "$RUNNER_TEMP/desktop-client"
npm install --prefix "$RUNNER_TEMP/desktop-client" --ignore-scripts --no-audit --no-fund socket.io-client@4.8.1
- name: Launch exact QA app and exercise disposable channel packets
env:
APP_BINARY: ${{ runner.temp }}/desktop-qa/Keeper Desktop R3 QA.app/Contents/MacOS/Keeper Desktop R3 QA
CLIENT_DIR: ${{ runner.temp }}/desktop-client
EVIDENCE_DIR: ${{ runner.temp }}/desktop-evidence
run: node .github/scripts/desktop_qa_cloud_smoke.mjs
- name: Preserve only sanitized outcomes
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: desktop-disposable-cloud-acceptance-${{ github.sha }}
path: ${{ runner.temp }}/desktop-evidence/
retention-days: 30
if-no-files-found: error
Loading