UNPKG

@didtools/siwx

Version:

Typescript library for Sign-In With X

13 lines (12 loc) 342 B
import { foldMap, match } from 'codeco/linear'; import { left, right } from 'codeco'; /** * Parse URI by checking if string could be parsed by `new URL` */ export const uri = foldMap(match(/^\S+/), (s)=>{ try { new URL(s); return right(s); } catch (e) { return left(new Error(`Invalid URI ${s}`)); } });