-
Notifications
You must be signed in to change notification settings - Fork 1
/
web-demo.html
70 lines (65 loc) · 2.17 KB
/
web-demo.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
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript"
src="https://unpkg.com/@passbase/button@v3/button.js"
></script>
<link rel="stylesheet" href="index.css" />
<title>Verify your Identity</title>
</head>
<body>
<img
class="img-fluid passbase"
src="https://passbase.com/assets/images/logo.png"
alt="Passbase"
/>
<div class="container">
<p class="title">Verify your identity now</p>
<p class="subtitle">
You can verify your identity in this Demo by clicking the verification
button below
</p>
<!-- 1. This is the Passbase Component -->
<div id="passbase-button"></div>
</div>
<script type="text/javascript">
// This is the logic for the Passbase component
const element = document.getElementById("passbase-button");
// update the below variable with your own publishable API key**your, which you can find in the [API settings](https://app.passbase.com/settings/api) section.
const apiKey = "YOUR_PUBLISHABLE_API_KEY";
Passbase.renderButton(element, apiKey, {
// Speed up the verification flow by providing some information you might already have like the user's email to skip the email step
prefillAttributes: {
email: "[email protected]",
},
onFinish: (identityAccessKey) => {
// Do what you want after the flow finished
// sendAuthKeyToBackend(identityAccessKey)
},
onError: (errorCode) => {},
onStart: () => {},
});
// Optional - Example to send identity access key to your backend
const sendAuthKeyToBackend = (identityAccessKey) => {
const body = {
identityAccessKey: identityAccessKey,
};
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
};
fetch("YOUR_BACKEND_POST_ENDPOINT", requestOptions)
.then(() => {
console.log("Success");
})
.catch((error) => {
console.log(error);
});
};
</script>
</body>
</html>