PageSourceSearch

https://walnutlens.com/js/signup-flow.js?v=5

js walnutlens.com collected 2026-10-02 01:48:07 UTC 2,894 bytes, 86 lines download raw bytes

1/* signup-flow.js — OTP + Discord API calls for inline checkout modal
2   Production version for new landing page */
3
4var API_BASE = 'https://kbpg3cxmcf.execute-api.eu-west-2.amazonaws.com';
5var INSTALL_ID = 'web-walnutview';
6
7/* ── API calls ── */
8
9async function requestOtp(email) {
10  var res = await fetch(API_BASE + '/v3/walnut/auth/request-otp', {
11    method: 'POST',
12    headers: { 'Content-Type': 'application/json' },
13    body: JSON.stringify({ email: email.trim().toLowerCase(), install_id: INSTALL_ID }),
14  });
15  if (!res.ok) {
16    var err = await res.json().catch(function() { return {}; });
17    throw new Error(err.reason || err.message || 'Request failed (' + res.status + ')');
18  }
19  return res.json();
20}
21
22async function verifyOtpWeb(email, otpCode, discordUsername) {
23  var res = await fetch(API_BASE + '/v3/walnut/auth/verify-otp', {
24    method: 'POST',
25    headers: { 'Content-Type': 'application/json' },
26    body: JSON.stringify({
27      email: email.trim().toLowerCase(),
28      otp_code: otpCode.trim(),
29      install_id: INSTALL_ID,
30      mode: 'email_only',
31      discord_username: discordUsername || null,
32    }),
33  });
34  if (!res.ok) {
35    var err = await res.json().catch(function() { return {}; });
36    throw new Error(err.reason || err.message || 'Verification failed (' + res.status + ')');
37  }
38  return res.json();
39}
40
41/* ── OTP input helpers ── */
42
43function initOtpInputs(container) {
44  var inputs = container.querySelectorAll('.otp-digit');
45  inputs.forEach(function(inp, i) {
46    inp.addEventListener('input', function() {
47      inp.value = inp.value.replace(/\D/g, '').slice(0, 1);
48      if (inp.value && i < inputs.length - 1) inputs[i + 1].focus();
49    });
50    inp.addEventListener('keydown', function(e) {
51      if (e.key === 'Backspace' && !inp.value && i > 0) inputs[i - 1].focus();
52    });
53    inp.addEventListener('paste', function(e) {
54      e.preventDefault();
55      var text = (e.clipboardData || window.clipboardData).getData('text').replace(/\D/g, '').slice(0, 6);
56      for (var j = 0; j < text.length && j < inputs.length; j++) {
57        inputs[j].value = text[j];
58      }
59      var next = Math.min(text.length, inputs.length - 1);
60      inputs[next].focus();
61    });
62  });
63}
64
65function getOtpValue(container) {
66  return Array.from(container.querySelectorAll('.otp-digit')).map(function(i) { return i.value; }).join('');
67}
68
69function clearOtpInputs(container) {
70  container.querySelectorAll('.otp-digit').forEach(function(i) { i.value = ''; });
71}
72
73/* ── Cooldown timer ── */
74
75function startCooldown(btn, seconds) {
76  var remaining = seconds;
77  btn.disabled = true;
78  var original = btn.textContent;
79  var tick = function() {
80    if (remaining <= 0) { btn.textContent = original; btn.disabled = false; return; }
81    btn.textContent = 'Resend (' + remaining + 's)';
82    remaining--;
83    setTimeout(tick, 1000);
84  };
85  tick();
86}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.