-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstytch.html
44 lines (35 loc) · 1.16 KB
/
stytch.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stytch HTTPOnly Test</title>
<script type="module">
import {StytchHeadlessClient} from "./js/stytch.esm.js";
const client = new StytchHeadlessClient("public-token-live-ecb6a1b5-ce12-4291-aa38-acabf0565fa1", {
endpointOptions: {
apiDomain: 'api.stytch.maxgerber.com',
}
})
document.getElementById("login").onclick = () => {
client.passwords.create({
email: `max+${(Math.random() + 1).toString(36).substring(7)}@stytch.com`,
password: 'ZXCVBNsucks!' + (Math.random() + 1).toString(36).substring(7),
session_duration_minutes: 60
})
}
document.getElementById("logout").onclick = () => {
client.session.revoke();
}
client.onStateChange((diff) => {
document.getElementById("loginstatus").innerText = JSON.stringify(diff)
})
window.stytch = client;
</script>
</head>
<body>
<h1>Stytch HTTPOnly Single Page Test</h1>
<button id="login">Login</button>
<button id="logout">Logout</button>
<p>Logged in? <code id="loginstatus"></code></p>
</body>
</html>