(value: unknown)
| 681 | } |
| 682 | |
| 683 | export function decodeTurnProviderRetry(value: unknown): TurnProviderRetry { |
| 684 | const record = requireRecord(value, 'Turn provider retry'); |
| 685 | const phase = record.phase; |
| 686 | const attempt = requirePositiveCount(record.attempt, 'attempt'); |
| 687 | const maxAttempts = requirePositiveCount(record.maxAttempts, 'maxAttempts'); |
| 688 | if (attempt > maxAttempts) throw invalidProtocolFrame('Invalid Turn provider retry'); |
| 689 | const reason = requireProviderRetryReason(record.reason); |
| 690 | if (phase === 'scheduled') { |
| 691 | assertExactKeys(record, 'scheduled Turn provider retry', [ |
| 692 | 'phase', |
| 693 | 'attempt', |
| 694 | 'maxAttempts', |
| 695 | 'delayMs', |
| 696 | 'reason', |
| 697 | ]); |
| 698 | return { |
| 699 | phase, |
| 700 | attempt, |
| 701 | maxAttempts, |
| 702 | delayMs: requireCount(record.delayMs, 'delayMs'), |
| 703 | reason, |
| 704 | }; |
| 705 | } |
| 706 | if (phase === 'started') { |
| 707 | assertExactKeys(record, 'started Turn provider retry', [ |
| 708 | 'phase', |
| 709 | 'attempt', |
| 710 | 'maxAttempts', |
| 711 | 'reason', |
| 712 | ]); |
| 713 | return { phase, attempt, maxAttempts, reason }; |
| 714 | } |
| 715 | throw invalidProtocolFrame('Invalid Turn provider retry'); |
| 716 | } |
| 717 | |
| 718 | function requireProviderRetryReason(value: unknown): ProviderRetryReason { |
| 719 | if ( |
no test coverage detected