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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.7.2

### Fixed

- **Permission handler uses single `RemotePermission`** — upstream 0.7.2 refined the spec to use a single `RemotePermission` per request (not batched array). The test host now matches.

### Changed

- **Dependencies** — `@novasamatech/host-api`, `host-container`, `product-sdk` → ^0.7.2. Upstream changes include ABI-stable method ordering, notification permission gate, and restored deprecated JSON-RPC methods for backward compatibility.

## 0.7.1

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parity/host-api-test-sdk",
"version": "0.7.1",
"version": "0.7.2",
"description": "Lightweight test host for Spektr product E2E testing — embeds dapps with auto-signing dev accounts, no Docker needed",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -42,11 +42,11 @@
}
},
"dependencies": {
"@novasamatech/host-api": "0.7.0"
"@novasamatech/host-api": "^0.7.2"
},
"devDependencies": {
"@novasamatech/host-container": "0.7.0",
"@novasamatech/product-sdk": "^0.7.0",
"@novasamatech/host-container": "^0.7.2",
"@novasamatech/product-sdk": "^0.7.2",
"@polkadot/keyring": "^14.0.0",
"@polkadot/types": "^16.0.0",
"@polkadot/util": "^14.0.0",
Expand Down
43 changes: 22 additions & 21 deletions pnpm-lock.yaml

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

53 changes: 23 additions & 30 deletions src/browser/host-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,41 +289,34 @@ function setupContainer(
});

// ── Permissions ─────────────────────────────────────────────
// Matches real host behavior: product must request permission
// before gated operations (e.g. signing requires TransactionSubmit).

container.handlePermission((params, { ok }) => {
// params is now RemotePermission[] (batched). Approve if all pass.
let allApproved = true;
for (const perm of params) {
let approved: boolean;
if (permissionBehavior === "approve-all") {
approved = true;
} else if (permissionBehavior === "reject-all") {
approved = false;
} else {
approved = permissionBehavior(perm.tag, perm.value);
}
// params is a single RemotePermission { tag, value }
let approved: boolean;
if (permissionBehavior === "approve-all") {
approved = true;
} else if (permissionBehavior === "reject-all") {
approved = false;
} else {
approved = permissionBehavior(params.tag, params.value);
}

if (approved) {
grantedPermissions.add(perm.tag);
} else {
allApproved = false;
}
if (approved) {
grantedPermissions.add(params.tag);
}

permissionLog.push({
tag: perm.tag,
value: perm.value,
approved,
timestamp: Date.now(),
});
permissionLog.push({
tag: params.tag,
value: params.value,
approved,
timestamp: Date.now(),
});

console.log(
`[test-host] Permission ${approved ? "granted" : "denied"}:`,
perm.tag,
);
}
return ok(allApproved);
console.log(
`[test-host] Permission ${approved ? "granted" : "denied"}:`,
params.tag,
);
return ok(approved);
});

// ── Device permissions ─────────────────────────────────────────
Expand Down
8 changes: 4 additions & 4 deletions test/test-product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ async function init() {

async requestChainSubmit(): Promise<TestResult> {
try {
const r = await hostApi.permission(enumValue('v1', [
const r = await hostApi.permission(enumValue('v1',
{ tag: 'ChainSubmit' as const, value: undefined },
]));
));
if (r.isOk()) {
return { ok: true, approved: r.value.value };
}
Expand All @@ -137,9 +137,9 @@ async function init() {

async requestRemote(url: string): Promise<TestResult> {
try {
const r = await hostApi.permission(enumValue('v1', [
const r = await hostApi.permission(enumValue('v1',
{ tag: 'Remote' as const, value: [url] },
]));
));
if (r.isOk()) {
return { ok: true, approved: r.value.value };
}
Expand Down
Loading