Skip to content

Instantly share code, notes, and snippets.

@fanuch
Created March 5, 2021 01:05
Show Gist options
  • Save fanuch/3814bf00992c8609cf48fb844f22177c to your computer and use it in GitHub Desktop.
Save fanuch/3814bf00992c8609cf48fb844f22177c to your computer and use it in GitHub Desktop.
Nodered-contrib-signal-client Working Patch to Add Catpcha to SMS and Voice Registration
--- ./nodered-contrib-signal-client/src/signal-client.html.orig 2021-03-03 18:02:33.441455002 +0100
+++ ./nodered-contrib-signal-client/src/signal-client.html 2021-03-03 18:25:22.420362403 +0100
@@ -95,6 +95,7 @@
defaults: {
server: { value: "", type: "remote-server" },
account: { value: "", type: "account" },
+ captcha: { value: "", required: false },
name: { value: "", required: false },
},
inputs: 0,
@@ -120,6 +121,10 @@
<input id="node-input-account">
</div>
<div class="form-row">
+ <label for="node-input-captcha"><i class="fa fa-registered"></i> Captcha Code</label>
+ <input type="text" id="node-input-captcha" placeholder="Captcha code for request">
+ </div>
+ <div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
@@ -139,6 +144,7 @@
defaults: {
server: { value: "", type: "remote-server" },
account: { value: "", type: "account" },
+ captcha: { value: "", required: false },
name: { value: "", required: false },
},
inputs: 0,
@@ -164,6 +170,10 @@
<input id="node-input-account">
</div>
<div class="form-row">
+ <label for="node-input-captcha"><i class="fa fa-registered"></i> Captcha Code</label>
+ <input type="text" id="node-input-captcha" placeholder="Captcha code for request">
+ </div>
+ <div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
--- ./nodered-contrib-signal-client/src/signal-client.js.orig 2021-03-03 18:02:33.441455002 +0100
+++ ./nodered-contrib-signal-client/src/signal-client.js 2021-03-03 18:23:51.554576318 +0100
@@ -101,7 +101,8 @@
this.account &&
this.account.phoneNumber &&
this.account.password &&
- this.account.protocolStore
+ this.account.protocolStore &&
+ config.captcha
) {
try {
const configuration = getConfiguration(this.account.liveServer);
@@ -111,7 +112,7 @@
this.account.protocolStore,
configuration,
);
- await accountManager.requestSMSVerification();
+ await accountManager.requestSMSVerification(config.captcha);
sendSuccess(node, "Signal client: registration code requested via sms.");
} catch (err) {
sendError(node, `Signal client error: ${JSON.stringify(err)}`);
@@ -137,7 +138,8 @@
this.account &&
this.account.phoneNumber &&
this.account.password &&
- this.account.protocolStore
+ this.account.protocolStore &&
+ config.captcha
) {
try {
const configuration = getConfiguration(this.account.liveServer);
@@ -147,7 +149,7 @@
this.account.protocolStore,
configuration,
);
- await accountManager.requestVoiceVerification();
+ await accountManager.requestVoiceVerification(config.captcha);
sendSuccess(node, "Signal client: registration code requested via voice call.");
} catch (err) {
sendError(node, `Signal client error: ${JSON.stringify(err)}`);
--- ./@gausma/libsignal-service-javascript/src/AccountManager.js.orig 2021-03-03 18:02:33.441455002 +0100
+++ ./@gausma/libsignal-service-javascript/src/AccountManager.js 2021-03-03 18:17:45.371410446 +0100
@@ -42,12 +42,12 @@
this.pending = Promise.resolve();
}
- requestVoiceVerification() {
- return this.server.requestVerificationVoice(this.username);
+ requestVoiceVerification(captcha) {
+ return this.server.requestVerificationVoice(this.username,captcha);
}
- requestSMSVerification() {
- return this.server.requestVerificationSMS(this.username);
+ requestSMSVerification(captcha) {
+ return this.server.requestVerificationSMS(this.username,captcha);
}
async encryptDeviceName(name, providedIdentityKey) {
--- ./@gausma/libsignal-service-javascript/src/WebAPI.js.orig 2021-03-03 18:02:33.445455083 +0100
+++ ./@gausma/libsignal-service-javascript/src/WebAPI.js 2021-03-03 18:19:42.961704660 +0100
@@ -631,19 +631,19 @@
});
}
- function requestVerificationSMS(number) {
+ function requestVerificationSMS(number,captcha) {
return _ajax({
call: 'accounts',
httpType: 'GET',
- urlParameters: `/sms/code/${number}`,
+ urlParameters: `/sms/code/${number}?captcha=`+captcha,
});
}
- function requestVerificationVoice(number) {
+ function requestVerificationVoice(number,captcha) {
return _ajax({
call: 'accounts',
httpType: 'GET',
- urlParameters: `/voice/code/${number}`,
+ urlParameters: `/voice/code/${number}?captcha=`+captcha,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment