siwe_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 371c94fa6345fc30f5a11bfc49b5f1cd4b204435eb6d6e4b4c53a46bac424131
4
+ data.tar.gz: bfdecc2b7e5a0bbc32bf38aeabb524da80d49c6708fc7331ee03f36d48fe647b
5
+ SHA512:
6
+ metadata.gz: 498b37111b3b6ccbf676311a5b0852bb8f8f77ed963482a35bcac1850f806794b6277c326dc695a99882eb4d2b1e56b3c8ebca02225802a14e8d8f561ab226e7
7
+ data.tar.gz: 7aae9b99106a7e75ae4583db235e2fa947d4d3c87fc645badf42984cbfd6f90686b1b02ec4c7b506ef2b0e8cb2b3538a5a7585f0ed868664f3ea8c5923d7cc39
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # SIWERails
2
+ [![GitHub Issues](https://img.shields.io/github/issues/spruceid/siwe_rails)](https://github.com/spruceid/siwe_rails/issues)
3
+ [![GitHub license](https://img.shields.io/github/license/spruceid/siwe_rails)](LICENSE)
4
+ [![Rails](https://img.shields.io/badge/Rails-%3E%3D%207.0.1-red)](https://github.com/spruceid/siwe_rails/blob/main/Gemfile.lock)
5
+ [![Visitors](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fspruceid%2Fsiwe_rails&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
6
+
7
+
8
+ Rails gem that adds SIWE local sign in routes.
9
+
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem "siwe_rails"
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install siwe_rails
26
+ ```
27
+
28
+ ## Usage
29
+ To use this plugin, just add `SiweRails::Engine` to your routes.
30
+
31
+ **Observe that the prefix where the routes are mounted must be set
32
+ correctly in the configuration step that follows.**
33
+
34
+ ```ruby
35
+ require 'siwe_rails'
36
+
37
+ Rails.application.routes.draw do
38
+ # other routes
39
+
40
+ mount SiweRails::Engine => '/my-prefix'
41
+
42
+ get '/auth/siwe/callback', to: 'my_controller#siwe_callback'
43
+ end
44
+ ```
45
+
46
+ The available configuration options are listed below:
47
+
48
+ ```ruby
49
+ config.x.siwe.prefix = 'my-prefix' # Prefix where the routes are mounted
50
+ config.x.siwe.statement = 'SIWE' # Message statement
51
+ config.x.siwe.expiration_time = 7 * 24 * 60 * 60 * 1000 # Message expiration time in milliseconds, 7 days by default
52
+ config.x.siwe.not_before = Time.now.utc.iso8601 # Message minimum datetime validity
53
+ config.x.siwe.request_id = false # Whether to add a request id
54
+ config.x.siwe.resources = nil # Resources
55
+ config.x.siwe.redirect_uri = '/auth/siwe/callback' # Redirect URL to receive user information on success
56
+
57
+ config.x.siwe.network = 'mainnet' # Network to use with sign in
58
+
59
+ config.x.siwe.infura = '898a72d2b3bd05900ac4582bcbb4dbdb' # Infura Key
60
+ config.x.siwe.portis = '3c128237-4235-472f-8223-3963111a9847' # Portis ID
61
+ config.x.siwe.fortmatic = 'pk_live_CBBD80D845392BAC' # Fortmatic Key
62
+
63
+ config.x.siwe.torus = true # Whether to enable Torus wallet
64
+ config.x.siwe.coinbase = true # Whether to enable Coinbase wallet, also requires Infura Key
65
+ ```
66
+
67
+ The front-end resources must be listed in your manifest like shown below:
68
+
69
+ ```
70
+ //= link siwe_rails/application.css
71
+ //= link siwe_rails/background.css
72
+ //= link siwe_rails/coinbase.svg
73
+ //= link siwe_rails/modal_icon.png
74
+ //= link siwe_rails/swe-landing.svg
75
+ //= link siwe_rails/web3bundle.js
76
+ //= link siwe_rails/siwe.js
77
+ ```
78
+
79
+ ### Callback
80
+
81
+ The callback will have the address and ens domain, if present,
82
+ available in the session object.
83
+
84
+ ```ruby
85
+ def siwe_callback
86
+ session[SiweRails.SIWE_ADDRESS]
87
+ session[SiweRails.SIWE_ENS]
88
+ end
89
+ ```
90
+
91
+ You can then use that to:
92
+ - Tie the account to a previous user of your application
93
+ (email, username, etc);
94
+ - Create a new account with the address/ens, or sign in.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ //= link_directory ../stylesheets/siwe_rails .css
2
+ //= link_directory ../images/siwe_rails .svg
3
+ //= link_directory ../images/siwe_rails .png
4
+ //= link_directory ../javascripts/siwe_rails .js
@@ -0,0 +1,4 @@
1
+ <svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="1024" height="1024" rx="512" fill="#0052FF"/>
3
+ <path d="M512.147 692C412.697 692 332.146 611.45 332.146 512C332.146 412.55 412.697 332 512.147 332C601.247 332 675.197 396.95 689.447 482H870.797C855.497 297.2 700.846 152 512.147 152C313.396 152 152.146 313.25 152.146 512C152.146 710.75 313.396 872 512.147 872C700.846 872 855.497 726.8 870.797 542H689.297C675.047 627.05 601.247 692 512.147 692Z" fill="white"/>
4
+ </svg>
@@ -0,0 +1,29 @@
1
+ <svg viewBox="0 0 1440 900" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0)">
3
+ <path
4
+ opacity="0.4"
5
+ d="M156.474 544.951C153.756 544.954 151.089 544.221 148.755 542.829C146.421 541.436 144.507 539.437 143.217 537.044L20.5949 319.469C19.3979 317.721 18.5771 315.743 18.1838 313.661C17.7904 311.579 17.8328 309.438 18.3095 307.374C18.7861 305.309 19.6865 303.367 20.9528 301.668C22.219 299.97 23.8236 298.553 25.6655 297.507C27.5075 296.462 29.5463 295.81 31.653 295.594C33.7596 295.378 35.8885 295.602 37.9042 296.252C39.9199 296.902 41.7783 297.963 43.3626 299.369C44.947 300.775 46.2228 302.495 47.1082 304.42L169.73 522.25C170.72 523.987 171.353 525.905 171.594 527.89C171.834 529.875 171.677 531.888 171.131 533.811C170.585 535.735 169.662 537.53 168.414 539.093C167.167 540.655 165.621 541.953 163.867 542.911C161.663 544.319 159.087 545.03 156.474 544.951ZM385.148 798.746L184.771 1133.14C184.326 1134.09 183.722 1134.95 182.986 1135.69L-118.598 1616.76C-119.969 1618.97 -121.884 1620.8 -124.159 1622.07C-126.435 1623.33 -128.995 1624 -131.599 1624C-134.203 1624 -136.764 1623.33 -139.039 1622.07C-141.315 1620.8 -143.229 1618.97 -144.601 1616.76L-653.191 805.378C-678.017 765.902 -691.443 720.322 -691.983 673.684C-692.523 627.045 -680.156 581.167 -656.25 541.125L-144.856 -317.442C-143.316 -320.067 -141.029 -322.173 -138.287 -323.491C-135.545 -324.809 -132.472 -325.279 -129.462 -324.841C-126.452 -324.402 -123.641 -323.076 -121.388 -321.032C-119.135 -318.987 -117.542 -316.316 -116.813 -313.361L387.952 540.36C411.356 579.495 423.48 624.346 422.985 669.949C422.49 715.552 409.395 760.129 385.148 798.746ZM-23.5085 816.091L70.8164 661.008C77.1088 650.735 80.5865 638.985 80.8998 626.941C81.2131 614.896 78.3513 602.981 72.6014 592.394L-116.303 274.832V372.524L-4.13336 568.673C3.76965 582.48 7.86383 598.141 7.72943 614.051C7.59503 629.962 3.23682 645.551 -4.89825 659.223L-30.3915 701.82C-31.7472 704.118 -33.6891 706.014 -36.0186 707.314C-38.348 708.614 -40.9811 709.271 -43.6479 709.217C-46.3419 709.3 -49.0011 708.591 -51.2958 707.176C-53.0419 706.176 -54.5695 704.835 -55.7883 703.233C-57.0071 701.631 -57.8925 699.801 -58.3917 697.851C-58.8909 695.901 -58.9941 693.87 -58.6948 691.879C-58.3956 689.888 -57.7001 687.978 -56.6496 686.26L-31.1564 643.409C-25.8151 634.436 -22.9526 624.205 -22.863 613.762C-22.7734 603.319 -25.4594 593.04 -30.6461 583.977L-116.303 434.251V587.803C-116.395 648.678 -97.8936 708.128 -63.2775 758.19L-23.5085 816.091ZM152.65 1126.51L-88.5161 775.535C-126.658 720.38 -147.029 654.874 -146.895 587.803V-253.93L-629.991 556.94C-651.014 592.108 -661.881 632.418 -661.386 673.393C-660.891 714.369 -649.053 754.404 -627.187 789.054L-131.599 1579.77L152.65 1126.51ZM361.694 556.174L-116.303 -252.399V-166.951L179.927 356.199C180.933 357.941 181.586 359.863 181.848 361.857C182.11 363.851 181.977 365.878 181.456 367.82C180.935 369.763 180.037 371.583 178.812 373.178C177.587 374.773 176.061 376.111 174.319 377.115C171.965 378.385 169.345 379.084 166.671 379.155C163.984 379.157 161.345 378.451 159.017 377.108C156.69 375.764 154.758 373.831 153.415 371.503L-116.303 -104.969V20.016L17.2807 248.559C18.3311 250.276 19.0266 252.187 19.3259 254.178C19.6251 256.169 19.5225 258.199 19.0233 260.149C18.5242 262.1 17.6387 263.93 16.4199 265.532C15.201 267.134 13.6735 268.475 11.9275 269.475C9.62134 270.863 6.97009 271.57 4.27948 271.516C1.61279 271.57 -1.02032 270.913 -3.34979 269.613C-5.67926 268.313 -7.62115 266.417 -8.97681 264.119L-116.303 80.4678V215.655L98.8589 576.835V577.345C107.211 592.723 111.394 610.02 110.992 627.517C110.589 645.014 105.615 662.101 96.5648 677.078L-5.15283 843.894L40.4797 909.957L180.692 681.159C189.36 666.875 201.852 639.072 186.556 613.055L174.064 591.374C173.058 589.632 172.406 587.71 172.144 585.716C171.881 583.722 172.014 581.696 172.535 579.753C173.056 577.811 173.955 575.99 175.179 574.395C176.404 572.8 177.931 571.462 179.673 570.458C183.203 568.494 187.359 567.981 191.261 569.028C195.162 570.076 198.504 572.601 200.577 576.07L213.069 597.496C229.894 626.829 227.855 663.049 206.695 697.228L59.3444 937.505L106.252 1005.61L284.195 718.144C294.363 701.633 299.894 682.685 300.208 663.294C300.523 643.903 295.607 624.786 285.979 607.954L186.556 435.016C184.528 431.498 183.979 427.318 185.03 423.396C186.082 419.473 188.648 416.129 192.164 414.1C195.68 412.07 199.858 411.522 203.778 412.574C207.698 413.626 211.04 416.194 213.069 419.712L312.492 592.649C324.846 614.279 331.152 638.838 330.749 663.747C330.345 688.656 323.246 712.996 310.198 734.214L125.117 1033.16L169.73 1098.2L358.38 782.677C358.635 782.677 358.635 782.677 358.635 782.422C379.971 748.669 391.551 709.664 392.09 669.73C392.63 629.797 382.11 590.493 361.694 556.174Z"
6
+ fill="url(#paint0_linear)"
7
+ />
8
+ <path
9
+ opacity="0.4"
10
+ d="M1859.47 168.951C1856.76 168.954 1854.09 168.221 1851.75 166.829C1849.42 165.436 1847.51 163.437 1846.22 161.044L1723.59 -56.5312C1722.4 -58.2791 1721.58 -60.2568 1721.18 -62.3387C1720.79 -64.4208 1720.83 -66.5616 1721.31 -68.6262C1721.79 -70.6907 1722.69 -72.6335 1723.95 -74.3319C1725.22 -76.0303 1726.82 -77.4471 1728.67 -78.4927C1730.51 -79.5382 1732.55 -80.1899 1734.65 -80.4061C1736.76 -80.6221 1738.89 -80.3979 1740.9 -79.7481C1742.92 -79.0983 1744.78 -78.037 1746.36 -76.631C1747.95 -75.225 1749.22 -73.5052 1750.11 -71.5804L1872.73 146.25C1873.72 147.987 1874.35 149.905 1874.59 151.89C1874.83 153.875 1874.68 155.888 1874.13 157.811C1873.59 159.735 1872.66 161.53 1871.41 163.093C1870.17 164.655 1868.62 165.953 1866.87 166.911C1864.66 168.319 1862.09 169.03 1859.47 168.951ZM2088.15 422.746L1887.77 757.144C1887.33 758.09 1886.72 758.952 1885.99 759.695L1584.4 1240.76C1583.03 1242.97 1581.12 1244.8 1578.84 1246.07C1576.57 1247.33 1574 1248 1571.4 1248C1568.8 1248 1566.24 1247.33 1563.96 1246.07C1561.69 1244.8 1559.77 1242.97 1558.4 1240.76L1049.81 429.378C1024.98 389.902 1011.56 344.322 1011.02 297.684C1010.48 251.045 1022.84 205.167 1046.75 165.125L1558.14 -693.442C1559.68 -696.067 1561.97 -698.173 1564.71 -699.491C1567.46 -700.809 1570.53 -701.279 1573.54 -700.841C1576.55 -700.402 1579.36 -699.076 1581.61 -697.032C1583.87 -694.987 1585.46 -692.316 1586.19 -689.361L2090.95 164.36C2114.36 203.495 2126.48 248.346 2125.99 293.949C2125.49 339.552 2112.39 384.129 2088.15 422.746ZM1679.49 440.091L1773.82 285.008C1780.11 274.735 1783.59 262.985 1783.9 250.941C1784.21 238.896 1781.35 226.981 1775.6 216.394L1586.7 -101.168V-3.47638L1698.87 192.673C1706.77 206.48 1710.86 222.141 1710.73 238.051C1710.6 253.962 1706.24 269.551 1698.1 283.223L1672.61 325.82C1671.25 328.118 1669.31 330.014 1666.98 331.314C1664.65 332.614 1662.02 333.271 1659.35 333.217C1656.66 333.3 1654 332.591 1651.7 331.176C1649.96 330.176 1648.43 328.835 1647.21 327.233C1645.99 325.631 1645.11 323.801 1644.61 321.851C1644.11 319.901 1644.01 317.87 1644.31 315.879C1644.6 313.888 1645.3 311.978 1646.35 310.26L1671.84 267.409C1677.18 258.436 1680.05 248.205 1680.14 237.762C1680.23 227.319 1677.54 217.04 1672.35 207.977L1586.7 58.2506V211.803C1586.61 272.678 1605.11 332.128 1639.72 382.19L1679.49 440.091ZM1855.65 750.512L1614.48 399.535C1576.34 344.38 1555.97 278.874 1556.1 211.803V-629.93L1073.01 180.94C1051.99 216.108 1041.12 256.418 1041.61 297.393C1042.11 338.369 1053.95 378.404 1075.81 413.054L1571.4 1203.77L1855.65 750.512ZM2064.69 180.174L1586.7 -628.399V-542.951L1882.93 -19.8009C1883.93 -18.0594 1884.59 -16.1368 1884.85 -14.1428C1885.11 -12.1487 1884.98 -10.1224 1884.46 -8.17981C1883.94 -6.2373 1883.04 -4.41669 1881.81 -2.82184C1880.59 -1.22699 1879.06 0.110657 1877.32 1.11475C1874.96 2.3847 1872.34 3.08374 1869.67 3.1554C1866.98 3.15717 1864.34 2.45087 1862.02 1.1076C1859.69 -0.235718 1857.76 -2.1687 1856.41 -4.4967L1586.7 -480.969V-355.984L1720.28 -127.441C1721.33 -125.724 1722.03 -123.813 1722.33 -121.822C1722.63 -119.831 1722.52 -117.801 1722.02 -115.851C1721.52 -113.9 1720.64 -112.07 1719.42 -110.468C1718.2 -108.866 1716.67 -107.525 1714.93 -106.525C1712.62 -105.137 1709.97 -104.43 1707.28 -104.484C1704.61 -104.43 1701.98 -105.087 1699.65 -106.387C1697.32 -107.687 1695.38 -109.583 1694.02 -111.881L1586.7 -295.532V-160.345L1801.86 200.835V201.345C1810.21 216.723 1814.39 234.02 1813.99 251.517C1813.59 269.014 1808.62 286.101 1799.56 301.078L1697.85 467.894L1743.48 533.957L1883.69 305.159C1892.36 290.875 1904.85 263.072 1889.56 237.055L1877.06 215.374C1876.06 213.632 1875.41 211.71 1875.14 209.716C1874.88 207.722 1875.01 205.696 1875.54 203.753C1876.06 201.811 1876.95 199.99 1878.18 198.395C1879.4 196.8 1880.93 195.462 1882.67 194.458C1886.2 192.494 1890.36 191.981 1894.26 193.028C1898.16 194.076 1901.5 196.601 1903.58 200.07L1916.07 221.496C1932.89 250.829 1930.85 287.049 1909.7 321.228L1762.34 561.505L1809.25 629.609L1987.2 342.144C1997.36 325.633 2002.89 306.685 2003.21 287.294C2003.52 267.903 1998.61 248.786 1988.98 231.954L1889.56 59.0159C1887.53 55.4982 1886.98 51.3182 1888.03 47.3958C1889.08 43.4733 1891.65 40.1295 1895.16 38.1C1898.68 36.0705 1902.86 35.5216 1906.78 36.574C1910.7 37.6263 1914.04 40.194 1916.07 43.7117L2015.49 216.649C2027.85 238.279 2034.15 262.838 2033.75 287.747C2033.35 312.656 2026.25 336.996 2013.2 358.214L1828.12 657.156L1872.73 722.199L2061.38 406.677C2061.63 406.677 2061.64 406.677 2061.64 406.422C2082.97 372.669 2094.55 333.664 2095.09 293.73C2095.63 253.797 2085.11 214.493 2064.69 180.174Z"
11
+ fill="url(#paint1_linear)"
12
+ />
13
+ </g>
14
+ <defs>
15
+ <linearGradient id="paint0_linear" x1="-274" y1="-147" x2="-794.437" y2="1772.63" gradientUnits="userSpaceOnUse">
16
+ <stop offset="0.0376269" stop-color="#04D2CA" />
17
+ <stop offset="0.159305" stop-color="#6A49E4" />
18
+ <stop offset="0.506479" stop-color="#0F0F0F" />
19
+ </linearGradient>
20
+ <linearGradient id="paint1_linear" x1="1429" y1="-523" x2="908.563" y2="1396.63" gradientUnits="userSpaceOnUse">
21
+ <stop offset="0.0376269" stop-color="#04D2CA" />
22
+ <stop offset="0.159305" stop-color="#6A49E4" />
23
+ <stop offset="0.506479" stop-color="#0F0F0F" />
24
+ </linearGradient>
25
+ <clipPath id="clip0">
26
+ <rect width="1440" height="900" fill="white" />
27
+ </clipPath>
28
+ </defs>
29
+ </svg>
@@ -0,0 +1,141 @@
1
+ const Web3Modal = window.Web3Modal.default;
2
+
3
+ const env = {
4
+ prefix: '<%= SiweRails.prefix %>',
5
+ network: '<%= SiweRails.network %>',
6
+ INFURA_ID: '<%= SiweRails.infura %>',
7
+ TORUS: '<%= SiweRails.torus %>',
8
+ PORTIS_ID: '<%= SiweRails.portis %>',
9
+ FORTMATIC_KEY: '<%= SiweRails.fortmatic %>',
10
+ COINBASE: '<%= SiweRails.coinbase %>',
11
+ };
12
+
13
+ const providerOptions = (() => {
14
+ const opt = {};
15
+
16
+ if (env.INFURA_ID) {
17
+ opt.walletconnect = {
18
+ package: Web3Bundle.WalletConnectProvider,
19
+ options: {
20
+ infuraId: env.INFURA_ID,
21
+ pollingInterval: 100000,
22
+ }
23
+ };
24
+ }
25
+
26
+ if (env.TORUS) {
27
+ opt.torus = {
28
+ package: Web3Bundle.Torus,
29
+ };
30
+ }
31
+
32
+ if (env.PORTIS_ID) {
33
+ opt.portis = {
34
+ package: Web3Bundle.Portis,
35
+ options: {
36
+ id: env.PORTIS_ID,
37
+ },
38
+ };
39
+ }
40
+
41
+ if (env.FORTMATIC_KEY) {
42
+ opt.fortmatic = {
43
+ package: Web3Bundle.Fortmatic,
44
+ options: {
45
+ key: env.FORTMATIC_KEY,
46
+ },
47
+ };
48
+ }
49
+
50
+ if (env.COINBASE && env.INFURA_ID) {
51
+ opt['custom-coinbase'] = {
52
+ display: {
53
+ logo: '<%= asset_path "siwe_rails/coinbase.svg" %>',
54
+ name: 'Coinbase',
55
+ description: 'Scan with WalletLink to connect',
56
+ },
57
+ options: {
58
+ appName: 'Sign-In with Ethereum',
59
+ networkUrl: `https://${env.network}.infura.io/v3/${env.INFURA_ID}`,
60
+ chainId: 1,
61
+ darkMode: false,
62
+ },
63
+ package: Web3Bundle.WalletLink,
64
+ connector: async (_, options) => {
65
+ const { appName, networkUrl, chainId, darkMode } = options;
66
+ const walletLink = new Web3Bundle.WalletLink({
67
+ appName,
68
+ darkMode,
69
+ });
70
+ const provider = walletLink.makeWeb3Provider(networkUrl, chainId);
71
+ await provider.enable();
72
+ return provider;
73
+ },
74
+ };
75
+ }
76
+
77
+ return opt;
78
+ })();
79
+
80
+ let web3Modal;
81
+
82
+ const signIn = async () => {
83
+ const walletProvider = await web3Modal.connect();
84
+ const provider = new ethers.providers.Web3Provider(walletProvider);
85
+
86
+ const [address] = await provider.listAccounts();
87
+ if (!address) {
88
+ throw new Error('Address not found.');
89
+ }
90
+
91
+ let ens;
92
+ try {
93
+ ens = await provider.lookupAddress(address);
94
+ } catch (error) {
95
+ console.error(error);
96
+ }
97
+
98
+ let { chainId } = await provider.getNetwork();
99
+
100
+ const message = await fetch(`${env.prefix}/message`,
101
+ {
102
+ method: 'POST',
103
+ headers: {
104
+ 'Content-Type': 'application/json',
105
+ 'X-CSRF-Token': getCSRF(),
106
+ },
107
+ credentials: 'include',
108
+ body: JSON.stringify({
109
+ chainId,
110
+ address,
111
+ })
112
+ }).then((res) => res.text());
113
+
114
+ const signature = await provider.getSigner().signMessage(message);
115
+
116
+ fetch(`${env.prefix}/signature`, {
117
+ method: 'POST',
118
+ headers: {
119
+ 'Content-Type': 'application/json',
120
+ 'X-CSRF-Token': getCSRF(),
121
+ },
122
+ credentials: 'include',
123
+ redirect: 'follow',
124
+ body: JSON.stringify({ signature, ens }),
125
+ });
126
+ };
127
+
128
+ const getCSRF = () => {
129
+ return document.querySelector('meta[name="csrf-token"]').content;
130
+ };
131
+
132
+ document.addEventListener('DOMContentLoaded', () => {
133
+ web3Modal = new Web3Modal({
134
+ network: env.network,
135
+ cacheProvider: true,
136
+ providerOptions,
137
+ });
138
+
139
+ let signInButton = document.getElementById('siwe');
140
+ signInButton.addEventListener('click', () => signIn());
141
+ });