import { decodeShareLink, encodeShareLink } from '@datamoc/mwg/core';
const link = await encodeShareLink({ type: 'state', id: 'pontifex@1.2.0', payload: { seed: 4242 } }, { base: 'https://example.org/play' });
const read = await decodeShareLink<{ seed: number }>(link);
console.log(read.ok && read.payload.seed); // 4242
Makes the link for an envelope; throws when the link is longer than
maxChars, so a caller that must always produce a link usesfitShareLinkorbisectShareLinkinstead.