/**
 * Copyright 2019 Twitter, Inc.
 * Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 */ import { validate } from "jsonschema" ; const CONFIG_SCHEMA = { $schema : "http://json-schema.org/draft-07/schema#" , $id : "http://twitter.github.io/sqrl/schema/Config" , title : "Config" , additionalProperties : false , properties : { "state.allow-in-memory" : { type : "boolean" , description : "Enable in-memory state storage if database addresses are not provided" , } , "redis.address" : { type : "string" , description : "Address of a redis server to use as storage" , } , "testing.fixed-date" : { type : "string" , description : "A fixed date time for testing" , } , } , patternProperties : { "^[.*]$" : { type : "object" , patternProperties : { "^[a-z][a-z-]*(.[a-z][a-z-]*)+$" : { } , } , } , } , } ; export interface Config { "state.allow-in-memory" ? : boolean ; "redis.address" ? : string ; "testing.fixed-date" ? : string ; [ packageName ] : any | { [ settingName ] : any ; } ; } const DEFAULT_CONFIG = { "state.allow-in-memory" : false , "redis.address" : process . env . SQRL_REDIS || null , } ; export function getConfigSchema ( ) { return CONFIG_SCHEMA ; } export function getDefaultConfig ( ) { return DEFAULT_CONFIG ; } export function validateConfig ( config ) { validate ( config , CONFIG_SCHEMA ) ; }