| 1 | import { bases } from 'multiformats/basics' |
| 2 | |
| 3 | // @ts-expect-error - Not easy to combine these types. |
| 4 | const multibaseDecoder = Object.values(bases).map(b => b.decoder).reduce((d, b) => d.or(b)) |
| 5 | |
| 6 | export function getBytes (str: string): Uint8Array { |
| 7 | str = str?.trim() |
| 8 | |
| 9 | if (str == null || str === '') { |
| 10 | throw new Error('Please enter a key') |
| 11 | } |
| 12 | |
| 13 | return multibaseDecoder.decode(str) |
| 14 | } |