Skip to content

Commit

Permalink
Implement deleteIdenfySession
Browse files Browse the repository at this point in the history
  • Loading branch information
calebtuttle committed Aug 3, 2023
1 parent 27eff82 commit dc1380c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/services/idenfy/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,25 @@ async function getIdenfySessionVerificationData(scanRef) {
}
}

async function redactVeriffSession(sessionId) {
async function deleteIdenfySession(scanRef) {
try {
const hmacSignature = createHmac("sha256", veriffSecretKey)
.update(Buffer.from(sessionId, "utf8"))
.digest("hex")
.toLowerCase();
const resp = await axios.delete(`https://api.veriff.me/v1/sessions/${sessionId}`, {
headers: {
"X-AUTH-CLIENT": veriffPublicKey,
"X-HMAC-SIGNATURE": hmacSignature,
"Content-Type": "application/json",
const resp = await axios.post(
"https://ivs.idenfy.com/api/v2/delete",
{
scanRef,
},
});
{
headers: {
"Content-Type": "application/json",
Authorization: `Basic ${Buffer.from(
`${idenfyApiKey}:${idenfyApiKeySecret}`
).toString("base64")}`,
},
}
);
return resp.data;
} catch (err) {
console.log(err.message);
console.log("idenfy/credentials: encountered error deleting session:", err);
return {};
}
}
Expand Down Expand Up @@ -403,7 +406,7 @@ async function getCredentials(req, res) {
);
response.metadata = creds;

await redactVeriffSession(scanRef);
await deleteIdenfySession(scanRef);

logWithTimestamp(`idenfy/credentials: Returning user whose UUID is ${uuid}`);

Expand Down

0 comments on commit dc1380c

Please sign in to comment.