-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathguide.js
More file actions
59 lines (55 loc) · 2.34 KB
/
Copy pathguide.js
File metadata and controls
59 lines (55 loc) · 2.34 KB
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
import {
authComponentBody,
authGuideHeader,
authSnippet,
passkeyComponentBody,
passkeyGuideHeader,
passkeyListSnippet,
} from '../utils/constants.js';
const guideHtml = `
<p class='paragraph'>
The <code class='language-bash'>@corbado/web-js</code> package provides a comprehensive solution for
integrating passkey-based authentication in any web application. It simplifies the process of managing
authentication states and user sessions with easy-to-use hooks and UI components.
</p>
<h2 id="guide-header" class='heading mt-7'></h2>
<p id="guide-body" class='paragraph mb-3'></p>
<ol>
<li class='paragraph'>
<h6 class='subheading'>1. Install the package</h6>
<pre class='language-bash'><code class='language-bash'>npm install @corbado/web-js</code></pre>
</li>
<li class='paragraph'>
<h6 class='subheading'>2. Load Corbado Application</h6>
<pre class='language-typescript'><code class='language-typescript'>import Corbado from '@corbado/web-js';
await Corbado.load({
projectId: 'pro-XXXXXXXXXXXXXXXXXXXX',
});</code></pre>
</li>
<li class='paragraph'>
<h6 class='subheading'>
3. Use <code id="auth-code-header" class='language-typescript'></code>
</h6>
<pre class='language-typescript'><code id="auth-code" class='language-typescript'></code></pre>
</li>
</ol>
`;
export function insertGuide(isAuthenticated) {
const guideElement = document.getElementById('guide');
if (guideElement) guideElement.innerHTML = guideHtml;
const guideHeader = document.getElementById('guide-header');
const guideBody = document.getElementById('guide-body');
const authCodeHeader = document.getElementById('auth-code-header');
const authCode = document.getElementById('auth-code');
if (isAuthenticated) {
if (guideHeader) guideHeader.innerHTML = passkeyGuideHeader;
if (guideBody) guideBody.innerHTML = passkeyComponentBody;
if (authCodeHeader) authCodeHeader.innerHTML = 'Corbado.mountPasskeyListUI()';
if (authCode) authCode.innerHTML = passkeyListSnippet;
} else {
if (guideHeader) guideHeader.innerHTML = authGuideHeader;
if (guideBody) guideBody.innerHTML = authComponentBody;
if (authCodeHeader) authCodeHeader.innerHTML = 'Corbado.mountAuthUI()';
if (authCode) authCode.innerHTML = authSnippet;
}
}