fix(core.gbapp): #387 adding /setupSecurity multiple tokens. Refresh token fix. @othonlima @christopherdecastilho.

This commit is contained in:
Rodrigo Rodriguez 2023-12-28 17:19:38 -03:00
parent 91034dab77
commit 1e0e60d37a
3 changed files with 37 additions and 11 deletions

View file

@ -88,7 +88,7 @@
"arraybuffer-to-buffer": "0.0.7",
"async-mutex": "0.4.0",
"async-promises": "0.2.3",
"async-retry": "^1.3.3",
"async-retry": "1.3.3",
"basic-auth": "2.0.1",
"billboard.js": "3.6.3",
"bluebird": "3.7.2",

View file

@ -161,7 +161,8 @@ export class GBVMService extends GBService {
"punycode": "2.1.1",
"@push-rpc/core": "1.8.2",
"@push-rpc/http": "1.8.2",
"vm2": "3.9.11"
"vm2": "3.9.11",
"async-retry": "1.3.3"
}
}`;
Fs.writeFileSync(urlJoin(folder, 'package.json'), packageJson);
@ -490,6 +491,7 @@ export class GBVMService extends GBService {
require('isomorphic-fetch');
const http = require('node:http');
const retry = require('async-retry');
const createRpcClient = require("@push-rpc/core").createRpcClient;
const createHttpClient = require("@push-rpc/http").createHttpClient;

View file

@ -375,9 +375,14 @@ export class KeywordsExpressions {
// Performs GET request using the constructed URL
await ensureTokens();
__data = await sys.getHttp ({pid: pid, file: __url, addressOrHeaders: headers, httpUsername, httpPs});
await retry(
async (bail) => {
await ensureTokens();
___data = await sys.getHttp ({pid: pid, file: __url, addressOrHeaders: headers, httpUsername, httpPs});
},{ retries: 5});
__data = ___data
// Updates current variable handlers.
__url = __data?.links?.next?.uri;
@ -671,8 +676,14 @@ export class KeywordsExpressions {
// Handles the GET http version.
else {
return `
await ensureTokens();
${$1} = await sys.getHttp ({pid: pid, file: ${$2}, addressOrHeaders: headers, httpUsername, httpPs})
await retry(
async (bail) => {
await ensureTokens();
__${$1} = await sys.getHttp ({pid: pid, file: ${$2}, addressOrHeaders: headers, httpUsername, httpPs})
},{ retries: 5});
${$1} = __${$1}
`;
}
}
@ -829,8 +840,14 @@ export class KeywordsExpressions {
const args = $2.split(',');
return `
await ensureTokens();
${$1} = await sys.postByHttp ({pid: pid, url:${args[0]}, data:${args[1]}, headers})
await retry(
async (bail) => {
await ensureTokens();
__${$1} = await sys.postByHttp ({pid: pid, url:${args[0]}, data:${args[1]}, headers})
},{ retries: 5});
${$1} = __${$1}
`;
}
];
@ -839,8 +856,15 @@ export class KeywordsExpressions {
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*put\s*(.*),\s*(.*)/gim,
($0, $1, $2, $3) => {
return `
await ensureTokens();
${$1} = await sys.putByHttp ({pid: pid, url:${$2}, data:${$3}, headers})
await retry(
async (bail) => {
await ensureTokens();
__${$1} = await sys.putByHttp ({pid: pid, url:${$2}, data:${$3}, headers})
},{ retries: 5});
${$1} = __${$1}
`;
}
];