|
1 | 1 | <script> |
2 | 2 | import { slide } from 'svelte/transition'; |
3 | 3 | import { PARAMS } from '$lib/constants.js'; |
| 4 | + import { validateProtocolParams as validate } from '$lib/validate.js'; |
| 5 | + import { generatePkce } from '$lib/utils'; |
4 | 6 | import ChevronY from '$components/ChevronY.svelte'; |
5 | 7 | import Tooltip from '$components/Tooltip.svelte'; |
6 | | - import { validateProtocolParams as validate } from '$lib/validate.js'; |
| 8 | + import RedoIcon from '../Icons/RedoIcon.svelte'; |
7 | 9 |
|
8 | 10 | let { |
9 | 11 | selectedProtocolParams = $bindable(), |
|
12 | 14 | selectedHelloParamsValues, |
13 | 15 | dropdowns = $bindable() |
14 | 16 | } = $props(); |
| 17 | +
|
| 18 | + async function regen(param) { |
| 19 | + if (param === 'nonce') { |
| 20 | + const { nonce } = await generatePkce(); |
| 21 | + selectedProtocolParamsValues.nonce = nonce; |
| 22 | + } else if (param === 'code_challenge') { |
| 23 | + const { code_challenge, code_verifier } = await generatePkce(); |
| 24 | + selectedProtocolParamsValues.code_challenge = code_challenge; |
| 25 | + selectedProtocolParamsValues.code_verifier = code_verifier; |
| 26 | + } else { |
| 27 | + console.error('Unknown parameter for regeneration', param); |
| 28 | + } |
| 29 | + } |
15 | 30 | </script> |
16 | 31 |
|
17 | 32 | <section class="break-inside-avoid-column"> |
|
94 | 109 | {/each} |
95 | 110 | </ul> |
96 | 111 | {:else} |
97 | | - <input |
98 | | - type="text" |
99 | | - class="form-input h-6 w-full border px-2" |
100 | | - class:opacity-50={!selected} |
101 | | - bind:value={selectedProtocolParamsValues[param.NAME]} |
102 | | - placeholder={param.PLACEHOLDER} |
103 | | - /> |
| 112 | + <div class="relative flex w-full items-center" class:opacity-50={!selected}> |
| 113 | + {#if param.REGENERATE} |
| 114 | + <button |
| 115 | + onclick={() => regen(param.NAME)} |
| 116 | + class="absolute right-0.5 z-10 inline-flex h-5 w-5 items-center justify-center border border-charcoal bg-charcoal dark:border-gray-800" |
| 117 | + > |
| 118 | + <RedoIcon /> |
| 119 | + </button> |
| 120 | + {/if} |
| 121 | + <input |
| 122 | + type="text" |
| 123 | + class="form-input h-6 w-full border px-2" |
| 124 | + class:pr-6={param.REGENERATE} |
| 125 | + bind:value={selectedProtocolParamsValues[param.NAME]} |
| 126 | + placeholder={param.PLACEHOLDER} |
| 127 | + /> |
| 128 | + </div> |
104 | 129 | {/if} |
105 | 130 | </li> |
106 | 131 | {/each} |
|
0 commit comments