| 397 | } |
| 398 | |
| 399 | function matchesStatePath(currentPath: string, patterns: string[]): boolean { |
| 400 | for (const pattern of patterns) { |
| 401 | if (pattern.endsWith(".*")) { |
| 402 | const prefix = pattern.slice(0, -2) |
| 403 | // "auth.tokens.*" matches "auth.tokens.access" but NOT "auth.tokens" itself |
| 404 | if (currentPath.startsWith(prefix + ".") && currentPath.length > prefix.length + 1) { |
| 405 | return true |
| 406 | } |
| 407 | } else if (currentPath === pattern) { |
| 408 | return true |
| 409 | } |
| 410 | } |
| 411 | return false |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Check whether a storage key (e.g. "auth:password", "auth_password", "user.api_key") |