1 | export const HARDENED = 0x80000000;
|
2 | export function hdValidatePath(path) {
|
3 | if (!path.startsWith('m/')) {
|
4 | return false;
|
5 | }
|
6 | const parts = path.split('/').slice(1);
|
7 | for (const p of parts) {
|
8 | const n = /^\d+'?$/.test(p)
|
9 | ? parseInt(p.replace(/'$/, ''), 10)
|
10 | : Number.NaN;
|
11 | if (isNaN(n) || (n >= HARDENED) || (n < 0)) {
|
12 | return false;
|
13 | }
|
14 | }
|
15 | return true;
|
16 | }
|