29std::optional<REMOTE_PROVIDER_OAUTH_SERVER_METADATA>
42 catch(
const std::exception& e )
44 aError = wxString::Format(
_(
"Unable to parse OAuth metadata: %s" ), wxString::FromUTF8( e.what() ) );
50 aError =
_(
"OAuth metadata must include authorization_endpoint and token_endpoint." );
55 _(
"authorization_endpoint" ) ) )
66 _(
"revocation_endpoint" ) ) )
78 schemaFile.AppendDir( wxS(
"schemas" ) );
84std::optional<REMOTE_PROVIDER_PART_MANIFEST>
92 const wxFileName& aSchemaFile,
93 bool aAllowInsecureLocalhost,
96 if( !aSchemaFile.IsFileReadable() )
98 aError = wxString::Format(
_(
"Remote provider manifest schema '%s' is not readable." ),
99 aSchemaFile.GetFullPath() );
105 validator.
Validate( aJson, handler );
109 aError = wxString::Format(
_(
"Remote provider manifest failed schema validation: %s" ), handler.
FirstError() );
122 for(
const nlohmann::json& assetJson : aJson.at(
"assets" ) )
130 asset.
size_bytes = assetJson.at(
"size_bytes" ).get<
long long>();
133 asset.
required = assetJson.at(
"required" ).get<
bool>();
136 _(
"assets[].download_url" ) ) )
141 manifest.
assets.push_back( asset );
144 catch(
const std::exception& e )
147 wxString::Format(
_(
"Unable to parse remote provider manifest: %s" ), wxString::FromUTF8( e.what() ) );
Collects JSON-schema validation errors so the caller can inspect them after a validation pass.
wxString FirstError() const
nlohmann::json Validate(const nlohmann::json &aJson, nlohmann::json_schema::error_handler &aErrorHandler, const nlohmann::json_uri &aInitialUri=nlohmann::json_uri("#")) const
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
wxString RemoteProviderJsonString(const nlohmann::json &aObject, const char *aKey)
Extract an optional string value from a JSON object, returning an empty wxString when the key is abse...
bool ValidateRemoteUrlSecurity(const wxString &aUrl, bool aAllowInsecureLocalhost, wxString &aError, const wxString &aLabel)
Validate that aUrl uses HTTPS, or HTTP on a loopback address when aAllowInsecureLocalhost is true.
static wxFileName DefaultSchemaPath()
std::vector< REMOTE_PROVIDER_PART_ASSET > assets
static std::optional< REMOTE_PROVIDER_PART_MANIFEST > FromJson(const nlohmann::json &aJson, bool aAllowInsecureLocalhost, wxString &aError)
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().