mirror of
https://github.com/paritytech/banana_split.git
synced 2026-09-14 11:06:18 +05:00
fix: apply the same shard-count validation to the generator
Share.vue's shard-count input had the defect Copilot flagged on Print.vue's: no `step`, no integer check, and `totalShards` fed straight into crypto.share() — a fractional count surfaced as an opaque secrets.js error routed through the generic error hub, and an emptied box passed "" through. Reuse `isValidShardCount()` and gate the generate button on it, matching the existing `secretTooLong` pattern (disabled button plus an inline error span), so both shard-count inputs now agree on what a shard count is.
This commit is contained in:
parent
19af5af007
commit
9f74cc3f6c
@ -39,13 +39,18 @@
|
||||
type="number"
|
||||
min="3"
|
||||
max="255"
|
||||
step="1"
|
||||
/>
|
||||
to reconstruct
|
||||
<br />
|
||||
<span v-if="!shardCountValid" class="error-text">
|
||||
Enter a whole number of shards between 3 and 255
|
||||
</span>
|
||||
</p>
|
||||
<button
|
||||
id="generateBtn"
|
||||
class="button-card"
|
||||
:disabled="secretTooLong"
|
||||
:disabled="secretTooLong || !shardCountValid"
|
||||
:hidden="encryptionMode"
|
||||
v-on:click="toggleMode"
|
||||
>
|
||||
@ -91,7 +96,7 @@
|
||||
<script lang="ts">
|
||||
import passPhrase from "../util/passPhrase";
|
||||
import crypto from "../util/crypto";
|
||||
import { defaultThreshold } from "../util/shards";
|
||||
import { defaultThreshold, isValidShardCount } from "../util/shards";
|
||||
|
||||
import ShardInfo from "../components/ShardInfo.vue";
|
||||
import CanvasText from "../components/CanvasText.vue";
|
||||
@ -121,6 +126,11 @@ export default Vue.extend({
|
||||
secretTooLong(): boolean {
|
||||
return this.secret.length > 1024;
|
||||
},
|
||||
// Gates generation the same way `secretTooLong` does: a fractional or empty
|
||||
// count would otherwise reach crypto.share() and fail deep inside secrets.js.
|
||||
shardCountValid(): boolean {
|
||||
return isValidShardCount(this.totalShards);
|
||||
},
|
||||
requiredShards(): number {
|
||||
return defaultThreshold(this.totalShards);
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user