@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 821 B
JavaScript
import e from"libphonenumber-js/examples.mobile.json";import{getCountries as n,getCountryCallingCode as o,isPossiblePhoneNumber as r,AsYouType as t,getExampleNumber as l}from"libphonenumber-js/min";export{getCountryCallingCode}from"libphonenumber-js/min";const i=(e,n)=>r(String(e),n),m=(e,n)=>`+${o(n)} ${e}`,p=e=>`*${e.replaceAll("-","").slice(-4)}`,a=e=>new t(e),u=n().map((e=>({code:e,callCode:o(e)}))),s=n=>{let o=l(n,e)?.formatInternational();return o?.substring(o.indexOf(" ")+1)},b=e=>{let n=new t;n.input(e);let o=n.getCountry()||"US",r=n.getCallingCode()||"1";return{countryCode:o,phone:e.replace("+"+r,"")}};export{u as countryCodesAndNumbers,m as formatPhoneNumber,b as getPhoneCountryCodeAndNumber,s as getPlaceholderPhoneNumber,p as lastFourDigits,a as phoneNumberTypingFormatter,i as validatePhoneNumber};