Remote response when pushing with LibGit2Sharp - libgit2

In LibGit2Sharp is there anyway to get the remote response when doing a Push?
When using something like the git bash command line you get the following output in the console:
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '3fe0a458ac'.
remote: Generating deployment script.
remote: Running deployment command...
remote: Handling Basic Web Site deployment.
The PushOptions provides pack building, transfer and error status during a Push operation, but ideally I'd like to catch the remote response (as listed above) and feed that back to the client. Any way to do this with libgit2 / LibGit2Sharp ?
Here is a snippet of my Push action using LibGit2Sharp version 0.16.0.0
using (var repository = new Repository(sourceRepositoryPath))
{
var pushOptions = new PushOptions
{
Credentials = new Credentials { Username = remoteUser, Password = remotePassword },
OnPackBuilderProgress = (stage, current, total) =>
{
Trace.WriteLine(string.Format("Pack Building Progress {0} out of {1}, Stage {2}",
current, total, stage));
return true;
},
OnPushStatusError = errors =>
{
Trace.WriteLine(errors);
},
OnPushTransferProgress = (current, total, bytes) =>
{
Trace.WriteLine(string.Format("Transfer Progress {0} out of {1}, Bytes {2}", current, total, bytes));
return true;
}
};
string pushRefSpec = string.Format("+{0}:{0}", "refs/heads/master");
var remote = repository.Network.Remotes["origin"];
repository.Network.Push(remote, pushRefSpec, pushOptions);
}

That information is being sent by the server process in a particular channel called 'progress', which requires an agreement between both parties that they support this extension. libgit2 itself has learnt how to do this, but libgit2sharp hasn't been updated yet to support this extra channel.
Once it does, it would look like Fetch's OnProgress.

Related

Provider Error : Provider : Transaction Reverted without Reason String

We have been working on Document Signing App which sends an email when a user uploads a document and sends it to sign to another 3-4 users.
The user gets the email and tries to sign the document which does a blockchain transaction whose status is always failed.
We have been trying to debug this but unfortunately we haven’t any details lately, We have tried various codes but no changes have changed the status of transaction.
Our System Details :
Provider : Alchemy
Network : Goerli / Localhost ( Hardhat node )
Local Dev : Hardhat
We also tried to use hardhat console.sol but we could not get any logs in the contract when using Hardhat node, No logs were printed using npx hardhat test.
We have been facing this problem since almost a week now and the transaction is stil failing.
Snapshot of Local Error :
ProviderError: Error: Transaction reverted without a reason string
at HttpProvider.request (node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
at GanacheGasMultiplierProvider.request (node_modules/hardhat/src/internal/core/providers/gas-providers.ts:312:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Smart Contract that is failing in actual transaction :
function sign(bytes32 hash, bytes32 signatureHash, address signer) public {
console.log("Entered Sign Function");
require(checkDoc(hash),"check doc failed");
require(documents[hash].signers[signer] == 1, "signer failed");
documents[hash].remainingSignatures--;
documents[hash].signers[signer] = block.timestamp;
emit Signature(hash, signatureHash, signer, 'Signature');
if (documents[hash].remainingSignatures == 0){
documents[hash].status = currentState.signed;
emit Signed(hash, 'Signed');
}
Require is not the issue because when we comment out require statements the transaction is still failing.
Code for Test case that is failing :
it("Signing contract", async function () {
const DocumentSigning = await ethers.getContractFactory("DocumentSigning");
const document_signing = await DocumentSigning.deploy();
const transactionOptions = {
gasLimit: 2500000
}
await document_signing.sign("0x46742b637a5c1d01460033c3bd178d1fafe78e0dffa5d2d1841dcccaf70d30a9", "0xef02795fa1b0c97abe843fb461b4625a6a24662bff227862d7d292c9fc69c1ab", "0x07906aae1204f6f3b81673562db7776af9acf83c", transactionOptions);
});
});
The values for test cases have been hardcoded for now to test the actual transaction flow.
Can some help on this as soon as possible?
Adding link to a sample transaction that failed :
https://goerli.etherscan.io/tx/0x4c1665f793541846457a27467236d5fccca63588be3064c78682f666393adc74

Chrome Extension - Migration to Manifest v3 - chrome.permissions user gesture issue

I have built a chrome extension in manifest version 2 and am now looking at migrating to version 3. As part of this migration I have come across an issue when trying to toggle an optional permission to use the chrome notifications api.
Since you can't request a new permission from a content script as the api is not accessible from a content script, you have to send a message to the background script to perform the request and return the response to the content script. This worked as expected with version 2, now I am receiving this error:
Unchecked runtime.lastError: This function must be called during a user gesture
This means that the extension wants the permission request to be initiated on the back of an event initiated by a user action, such as a click. This indicates that the extension wishes the permission request to be completed from the content script but as stated above this is impossible.
Could anyone illuminate me if I'm missing something?
Content Script:
chrome.runtime.sendMessage(
{message: 'requestPermissions', permissions: ['notifications']},
(res) => console.log(res)
);
Background Script:
export function requestPermissions(request, sender, sendResponse) {
const {permissions} = request;
new Promise((resolve) => {
chrome.permissions.request(
{
permissions
},
(granted) => resolve(granted)
);
}).then((res) => sendResponse(res));
return true;
}

Error parsing triggers: Cannot find module 'firebase/firestore'

I am trying to run a very basic code on google api using firebase.
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
//const {Card, Suggestion} = require('dialogflow-fulfillment');
var admin = require('firebase-admin');
require("firebase/firestore");
admin.initializeApp(functions.config().firebase);
//var firestore = admin.firestore();
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
//firestore arguments defined
/* var addRef = firestore.collection('Admissions');
var feeRef = firestore.collection('Fees');
*/
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
console.log("request.body.queryResult.parameters: ", request.body.queryResult.parameters);
// Run the proper function handler based on the matched Dialogflow intent name
var intentMap = new Map();
});
It gives me a error that says
'Error parsing triggers: Cannot find module 'firebase/firestore'.Try running "npm install" in your functions directory before deploying.
When I run npm install inside the funtions directory, I get:
audited 9161 packages in 25.878s found 292 vulnerabilities (21 low,
207 moderate, 64 high) run npm audit fix to fix them, or npm
audit for details
Its been a week, I am stuck with these errors, these errors keep fluctuating based on the solution i find. But i am not able to overcome this error. Can you please check if there is something wrong I am doing, or anything else I need to try?
Just delete the node_modules folder and run npm install again. I was also stuck on this for a week. It is a corrupt file issue.

Gulp task to SSH and then mysqldump

So I've got this scenario where I have separate Web server and MySQL server, and I can only connect to the MySQL server from the web server.
So basically everytime I have to go like:
step 1: 'ssh -i ~/somecert.pem ubuntu#1.2.3.4'
step 2: 'mysqldump -u root -p'password' -h 6.7.8.9 database_name > output.sql'
I'm new to gulp and my aim was to create a task that could automate all this, so running one gulp task would automatically deliver me the SQL file.
This would make the developer life a lot easier since it would just take a command to download the latest db dump.
This is where I got so far (gulpfile.js):
////////////////////////////////////////////////////////////////////
// Run: 'gulp download-db' to get latest SQL dump from production //
// File will be put under the 'dumps' folder //
////////////////////////////////////////////////////////////////////
// Load stuff
'use strict'
var gulp = require('gulp')
var GulpSSH = require('gulp-ssh')
var fs = require('fs');
// Function to get home path
function getUserHome() {
return process.env.HOME || process.env.USERPROFILE;
}
var homepath = getUserHome();
///////////////////////////////////////
// SETTINGS (change if needed) //
///////////////////////////////////////
var config = {
// SSH connection
host: '1.2.3.4',
port: 22,
username: 'ubuntu',
//password: '1337p4ssw0rd', // Uncomment if needed
privateKey: fs.readFileSync( homepath + '/certs/somecert.pem'), // Uncomment if needed
// MySQL connection
db_host: 'localhost',
db_name: 'clients_db',
db_username: 'root',
db_password: 'dbp4ssw0rd',
}
////////////////////////////////////////////////
// Core script, don't need to touch from here //
////////////////////////////////////////////////
// Set up SSH connector
var gulpSSH = new GulpSSH({
ignoreErrors: true,
sshConfig: config
})
// Run the mysqldump
gulp.task('download-db', function(){
return gulpSSH
// runs the mysql dump
.exec(['mysqldump -u '+config.db_username+' -p\''+config.db_password+'\' -h '+config.db_host+' '+config.db_name+''], {filePath: 'dump.sql'})
// pipes output into local folder
.pipe(gulp.dest('dumps'))
})
// Run search/replace "optional"
SSH into the web server runs fine, but I have an issue when trying to get the mysqldump, I'm getting this message:
events.js:85
throw er; // Unhandled 'error' event
^
Error: Warning:
If I try the same mysqldump command manually from the server SSH, I get:
Warning: mysqldump: unknown variable 'loose-local-infile=1'
Followed by the correct mylsql dump info.
So I think this warning message is messing up my script, I would like to ignore warnings in cases like this, but don't know how to do it or if it's possible.
Also I read that using the password directly in the command line is not really good practice.
Ideally, I would like to have all the config vars loaded from another file, but this is my first gulp task and not really familiar with how I would do that.
Can someone with experience in Gulp orient me towards a good way of getting this thing done? Or do you think I shouldn't be using Gulp for this at all?
Thanks!
As I suspected, that warning message was preventing the gulp task from finalizing, I got rid of it by commenting the: loose-local-infile=1 From /etc/mysql/my.cnf

Can't get GCM push messages being sent properly

So my GCM push message works if I use this test link
http://www.androidbegin.com/tutorial/gcm.html
Here's the response
{ "multicast_id":7724943165862866717,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1418649384921891% 7fd2b314f9fd7ecd"}]}
However if I push using my own service using node push service using the toothlessgear/node-gcm lib
https://github.com/ToothlessGear/node-gcm I get a success message on the server but no msg makes it to the client
{ multicast_id: 5130374164465991000,
success: 1,
failure: 0,
canonical_ids: 0,
results: [ { message_id: '0:1418649238305331%7fd2b3145bca2e79' } ] }
I also tried the same message using pushwoosh and push woosh doesn't work either. How come I'm getting a success message on the server, but no push is received on the client on the latter two services. Is there some sort of ip configuration that I need to do, or some sort of certificate? I've used the same google api server key which is open to all ips on all 3 of these services.
Why does the response show success on the latter but no msg gets received on the client?
Node service server side code
var gcm = require('node-gcm');
// create a message with default values
var message = new gcm.Message();
// or with object values
var message = new gcm.Message({
collapseKey: 'demo',
delayWhileIdle: true,
timeToLive: 3,
data: {
key1: 'message1',
key2: 'message2'
}
});
var sender = new gcm.Sender('insert Google Server API Key here');
var registrationIds = ['regId1'];
/**
* Params: message-literal, registrationIds-array, No. of retries, callback-function
**/
sender.send(message, registrationIds, 4, function (err, result) {
console.log(result);
});
So the pushes were correctly being sent, my issue was with the cordova plugin on the client which requires that the android payload for "message" or "title" be set. The sample php just coincidentally was setting the message property and that's why it worked.
Updating the code to add the following to the data
data: {message:'test'}
works correctly