Skip to content

Commit

Permalink
Try to fix error in fetching values
Browse files Browse the repository at this point in the history
  • Loading branch information
giade committed Nov 22, 2023
1 parent 6bdbd14 commit cf5e677
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jumpgroup/secret-fetcher",
"version": "1.6.2",
"version": "1.6.3",
"author": "JumpGroup srl",
"main": "src/index.js",
"license": "MIT",
Expand Down
15 changes: 15 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const domain = "https://passwdservice.jumpgroup.it";

// Get the variables from the remote server
const getRemoteKeys = async (groupKey, groupSecret) => {

const baseUrl = domain + '/api/passwords';

const params = '?word=' + groupKey + '&encrypted_word=' + groupSecret;
Expand All @@ -18,6 +19,8 @@ const getRemoteKeys = async (groupKey, groupSecret) => {
redirect: 'follow',
};

console.log("Fetch secrets from Passwd");

var result = await fetch(baseUrl + params, requestOptions).then((res) => {
return res.json();
}).then((json) => {
Expand All @@ -27,6 +30,18 @@ const getRemoteKeys = async (groupKey, groupSecret) => {
const tagToObjectMap = {};

//create a map of tags to objects

while (!Array.isArray(result)) {
console.log("Error while getting secrets from Passwd");
result = await fetch(baseUrl + params, requestOptions).then((res) => {
return res.json();
}).then((json) => {
return json;
});
}

console.log("Parsing Received Secrets");

result.forEach(item => {
item.tags.forEach(tag => {
const [tagGroup, tagValue] = tag.split(":");
Expand Down

0 comments on commit cf5e677

Please sign in to comment.