Skip to content

Commit 4f2c2ec

Browse files
committed
Gateway/Pairing: restore scope allow helper #20703 thanks @coygeek
1 parent 9e3f969 commit 4f2c2ec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/infra/device-pairing.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ function mergePendingDevicePairingRequest(
177177
};
178178
}
179179

180+
function scopesAllow(requested: string[], allowed: string[]): boolean {
181+
if (requested.length === 0) {
182+
return true;
183+
}
184+
if (allowed.length === 0) {
185+
return false;
186+
}
187+
const allowedSet = new Set(allowed);
188+
return requested.every((scope) => allowedSet.has(scope));
189+
}
190+
180191
const DEVICE_SCOPE_IMPLICATIONS: Readonly<Record<string, readonly string[]>> = {
181192
"operator.admin": ["operator.read", "operator.write", "operator.approvals", "operator.pairing"],
182193
"operator.write": ["operator.read"],

0 commit comments

Comments
 (0)