-
Notifications
You must be signed in to change notification settings - Fork 8
/
yat.html
113 lines (107 loc) · 5.88 KB
/
yat.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
layout: root
title: Yat -
permalink: /yat
---
<div id="malformed-url" class="wrap bodytext">
Oops, you probably ended up here by accident
</div>
<div id="yat-instructions" class="wrap bodytext">
<p><h2>Yat wallet integration has arrived</h2></p>
<p>MyMonero users can now link their existing Yats to their MyMonero wallets</p>
<p>Users can also purchase Yats through MyMonero</p>
<p>To get started, download the April 2022 desktop release. Support for Android and iOS will be released soon</p>
</div>
<div id="macintosh-instructions" class="wrap bodytext">
<p>Congratulations on linking your Yat</p>
<p>To complete the process, your device will now attempt to open MyMonero.</p>
<p>Didn't succeed? Click <a class="retry-link" target="_blank" href="">Here</a></p>
</div>
<div id="windows-instructions" class="wrap bodytext">
<p>Congratulations on linking your Yat</p>
<p>To complete the process, your device will now attempt to open MyMonero.</p>
<p>Didn't succeed? Click <a class="retry-link" target="_blank" href="">Here</a></p>
</div>
<div id="android-instructions" class="wrap bodytext">
<p>Congratulations on linking your Yat</p>
<p>To complete the process, your device will now attempt to open MyMonero.</p>
<p>Didn't succeed? Click <a class="retry-link" target="_blank" href="">Here</a></p>
</div>
<div id="ios-instructions" class="wrap bodytext">
<p>Congratulations on linking your Yat</p>
<p>To complete the process, you will need to click the link above to open MyMonero.</p>
<!-- <p>Didn't succeed? Click <a href="">Here</a></p> -->
</div>
<div id="linux-instructions" class="wrap bodytext">
<p>Congratulations on linking your Yat</p>
<p>To complete the process, your device will now attempt to open MyMonero.</p>
<p>Didn't succeed? Click <a class="retry-link" target="_blank" href="">Here</a></p>
</div>
<style>
.bodytext {
display: none;
}
</style>
<script>
// This code is for Yat deep link support
let url = new URL(window.location.href);
let eid = url.searchParams.get("eid");
let refresh_token = url.searchParams.get("refresh_token");
let userAgent = navigator.userAgent;
let validationSucceeded;
// explicitly check params are safe to inject into a URL
if (eid !== null) {
try {
eid = decodeURIComponent(eid);
let regex = /^[A-z0-9-_]+$/
let refresh_tokenIsAlphanumeric = refresh_token.match(regex);
if (refresh_tokenIsAlphanumeric == "array") {
throw new Error("Non-alphanumeric refresh_token");
}
validationSucceeded = true;
} catch (error) {
validationSucceeded = false;
throw error;
}
if (validationSucceeded) {
let redirectUrl;
if (userAgent.indexOf("Android") !== -1) {
let element = document.getElementById("android-instructions")
element.style.display = "block";
// console.log("Android")
redirectUrl = "mymonero://yat-deep-link?" + "eid=" + eid + "&refresh_token=" + refresh_token;
} else if (userAgent.indexOf("iOS") !== -1) {
let element = document.getElementById("ios-instructions")
element.style.display = "block";
// Add a message to the page body telling the user to click the "Open in MyMonero" link at the top of the screen
// console.log("iOS")
} else if (userAgent.indexOf("Windows") !== -1) {
let element = document.getElementById("windows-instructions")
element.style.display = "block";
redirectUrl = "mymonero://yat-deep-link?" + "eid=" + eid + "&refresh_token=" + refresh_token;
// console.log("Windows")
} else if (userAgent.indexOf("Macintosh") !== -1) {
let element = document.getElementById("macintosh-instructions")
// console.log(element);
element.style.display = "block";
// console.log("Macintosh")
// mymonero://yat-deep-link?eid=%F0%9F%98%82%F0%9F%98%82%F0%9F%98%82%F0%9F%98%82%F0%9F%98%82&refresh_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2NTEyZDZhNy1kMTc3LTQ0NjktYjMwMy0xYWE0OTlhZjgyYjUiLCJpc3MiOiJlbW9qaS1pZC10b2tlbi1pc3N1ZXIiLCJleHAiOjE2NTExNDMyMDYsInNjb3BlcyI6WyJ0b2tlbjpyZWZyZXNoIl0sImlzc3VlZCI6MTY0ODQ2NDgwNiwiYWN0aXZlMmZhIjowfQ.bkkslCMILtug0dzN9rsc_4kZ-WCga05Xd5nYrsDzn-Q
redirectUrl = "mymonero://yat-deep-link?" + "eid=" + eid + "&refresh_token=" + refresh_token;
} else {
// We assume the user is on Linux
redirectUrl = "mymonero://yat-deep-link?" + "eid=" + eid + "&refresh_token=" + refresh_token;
}
let retryLinks = document.getElementsByClassName("retry-link");
for (let elem of retryLinks) {
elem.href = redirectUrl;
}
window.location.href = redirectUrl;
} else {
let element = document.getElementById("malformed-url");
element.style.display = "block"
}
} else {
let element = document.getElementById("yat-instructions");
element.style.display = "block"
}
</script>