do not add provider without salt

This commit is contained in:
Sebastian 2022-06-03 12:18:45 -03:00
parent 78b5518185
commit 8e9bca396e
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -169,8 +169,8 @@ export class ReducerError extends Error {
constructor(public errorJson: ErrorDetails) { constructor(public errorJson: ErrorDetails) {
super( super(
errorJson.message ?? errorJson.message ??
errorJson.hint ?? errorJson.hint ??
`${TalerErrorCode[errorJson.code]}`, `${TalerErrorCode[errorJson.code]}`,
); );
// Set the prototype explicitly. // Set the prototype explicitly.
@ -301,6 +301,13 @@ async function getProviderInfo(
} }
try { try {
const jsonResp: EscrowConfigurationResponse = await resp.json(); const jsonResp: EscrowConfigurationResponse = await resp.json();
if (!jsonResp.provider_salt) {
return {
status: "error",
code: TalerErrorCode.ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED,
hint: "provider did not have provider salt",
}
}
return { return {
status: "ok", status: "ok",
http_status: 200, http_status: 200,
@ -552,8 +559,8 @@ async function uploadSecret(
"content-type": "application/json", "content-type": "application/json",
...(paySecret ...(paySecret
? { ? {
"Anastasis-Payment-Identifier": paySecret, "Anastasis-Payment-Identifier": paySecret,
} }
: {}), : {}),
}, },
body: JSON.stringify(tur), body: JSON.stringify(tur),
@ -644,8 +651,8 @@ async function uploadSecret(
[ANASTASIS_HTTP_HEADER_POLICY_META_DATA]: metadataEnc, [ANASTASIS_HTTP_HEADER_POLICY_META_DATA]: metadataEnc,
...(paySecret ...(paySecret
? { ? {
"Anastasis-Payment-Identifier": paySecret, "Anastasis-Payment-Identifier": paySecret,
} }
: {}), : {}),
}, },
body: decodeCrock(encRecoveryDoc), body: decodeCrock(encRecoveryDoc),
@ -656,12 +663,12 @@ async function uploadSecret(
let policyExpiration: TalerProtocolTimestamp = { t_s: 0 }; let policyExpiration: TalerProtocolTimestamp = { t_s: 0 };
try { try {
policyVersion = Number(resp.headers.get("Anastasis-Version") ?? "0"); policyVersion = Number(resp.headers.get("Anastasis-Version") ?? "0");
} catch (e) {} } catch (e) { }
try { try {
policyExpiration = { policyExpiration = {
t_s: Number(resp.headers.get("Anastasis-Policy-Expiration") ?? "0"), t_s: Number(resp.headers.get("Anastasis-Policy-Expiration") ?? "0"),
}; };
} catch (e) {} } catch (e) { }
successDetails[prov.provider_url] = { successDetails[prov.provider_url] = {
policy_version: policyVersion, policy_version: policyVersion,
policy_expiration: policyExpiration, policy_expiration: policyExpiration,