http-connector.ais
execute(input)
partner = service "http_partner"
signature = signPayload(input.payload)
// Send exactly the bytes that were signed, without reserialization.
try
result = partner.send(signature.bytes, { headers: { "X-Signature": signature.value } })
if result.status != 200
fail Unavailable "Partner did not provide a successful response"
end
payload = Object.parse(Bytes.decode(result.bytes))
return { reference: payload.reference, status: payload.status }
catch Unavailable
// A timeout does not prove that the remote action did not happen.
return { reference: input.reference, status: "unknown" }
end
end
signPayload(payload)
secrets = service "secrets_default"
keyId = property("security.secrets.partnerSigningKey")
if keyId == null
fail Unavailable "Partner signing key is not configured"
end
bytes = Bytes.encode(payload)
value = secrets.sign(keyId, bytes, { algorithm: "HmacSHA256" })
return { bytes: bytes, value: value }
end
All examples