Skip to content

Commit 46cc818

Browse files
committed
Enable Signal CAPTCHA token passback to Signal-Windows
1 parent 007fa1c commit 46cc818

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

SignalCaptcha/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>SignalCaptcha</title>
5+
<title>CAPTCHA for Signal Private Messenger</title>
66
<link href="lib/winjs-4.0.1/css/ui-light.css" rel="stylesheet" />
77
<script src="lib/winjs-4.0.1/js/base.js"></script>
88
<script src="lib/winjs-4.0.1/js/ui.js"></script>
99
<link href="css/default.css" rel="stylesheet" />
1010
<script src="js/main.js"></script>
1111
</head>
1212
<body class="win-type-body">
13-
<div>Content goes here!</div>
1413
</body>
1514
</html>

SignalCaptcha/js/main.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,37 @@
99
var isFirstActivation = true;
1010

1111
app.onactivated = function (args) {
12-
if (args.detail.kind === activation.ActivationKind.voiceCommand) {
13-
// TODO: Handle relevant ActivationKinds. For example, if your app can be started by voice commands,
14-
// this is a good place to decide whether to populate an input field or choose a different initial view.
15-
}
16-
else if (args.detail.kind === activation.ActivationKind.launch) {
17-
// A Launch activation happens when the user launches your app via the tile
18-
// or invokes a toast notification by clicking or tapping on the body.
19-
if (args.detail.arguments) {
20-
// TODO: If the app supports toasts, use this value from the toast payload to determine where in the app
21-
// to take the user in response to them invoking a toast notification.
22-
}
23-
else if (args.detail.previousExecutionState === activation.ApplicationExecutionState.terminated) {
24-
// TODO: This application had been suspended and was then terminated to reclaim memory.
25-
// To create a smooth user experience, restore application state here so that it looks like the app never stopped running.
26-
// Note: You may want to record the time when the app was last suspended and only restore state if they've returned after a short period.
27-
}
28-
}
12+
if (args.detail.kind === activation.ActivationKind.voiceCommand) {
13+
// TODO: Handle relevant ActivationKinds. For example, if your app can be started by voice commands,
14+
// this is a good place to decide whether to populate an input field or choose a different initial view.
15+
}
16+
else if (args.detail.kind === activation.ActivationKind.launch) {
17+
// A Launch activation happens when the user launches your app via the tile
18+
// or invokes a toast notification by clicking or tapping on the body.
19+
if (args.detail.arguments) {
20+
// TODO: If the app supports toasts, use this value from the toast payload to determine where in the app
21+
// to take the user in response to them invoking a toast notification.
22+
}
23+
else if (args.detail.previousExecutionState === activation.ApplicationExecutionState.terminated) {
24+
// TODO: This application had been suspended and was then terminated to reclaim memory.
25+
// To create a smooth user experience, restore application state here so that it looks like the app never stopped running.
26+
// Note: You may want to record the time when the app was last suspended and only restore state if they've returned after a short period.
27+
}
28+
}
29+
else if (args.detail.kind === activation.ActivationKind.protocol) {
30+
const originalUri = args.detail.uri.rawUri;
31+
const token = originalUri.substring(16);
32+
const newUri = "signalpassback://?" + token;
33+
const launcherOptions = new Windows.System.LauncherOptions();
34+
launcherOptions.targetApplicationPackageFamilyName = "2383BenediktRadtke.SignalPrivateMessenger_teak1p7hcx9ga";
35+
const inputData = new Windows.Foundation.Collections.ValueSet();
36+
inputData.insert("token", token);
37+
Windows.System.Launcher.launchUriAsync(new Windows.Foundation.Uri(newUri), launcherOptions, inputData).then(function (value) {
38+
if (value) {
39+
Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryConsolidateAsync();
40+
}
41+
});
42+
}
2943

3044
if (!args.detail.prelaunchActivated) {
3145
// TODO: If prelaunchActivated were true, it would mean the app was prelaunched in the background as an optimization.

0 commit comments

Comments
 (0)