let nanoid ; try { nanoid = require ( 'nanoid' ) ; } catch ( error ) { nanoid = require ( 'nanoid/non-secure' ) ; } import { FUNCTION_BASE_URL , LOCAL_SESSION_KEY , LOCAL_KEY_PREFIX , USER_BASE_URL } from '../const' ; export function getLocalSessionKey ( serviceId ) { return `${ LOCAL_KEY_PREFIX }:${ serviceId }:${ LOCAL_SESSION_KEY }` ; } export function generateSession ( ) { return nanoid ( ) ; } export function getBaseURL ( serviceId ) { return FUNCTION_BASE_URL . replace ( '{serviceId}' , serviceId ) ; } export function getUserOAuthBaseURL ( serviceId ) { return USER_BASE_URL . replace ( '{serviceId}' , serviceId ) ; } param ms export const sleep = async ( ms = 1000 ) => { return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; } ;