-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
227 lines (211 loc) · 9.1 KB
/
index.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-okaidia.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-typescript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-rust.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-go.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-bash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-elixir.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-java.min.js"></script>
<title>Code Switcher</title>
</head>
<body>
<header class="header">
<div class="header__inner">
<div class="header_inner-left">
<div class="mobile-menu-icon">
<i class="fas fa-bars"></i>
</div>
<h1 class="header__title">CodeSwitch</h1>
</div>
<nav class="header__nav">
<a href="#" class="header__link">About</a>
<a href="#" class="header__link">Blog</a>
<a href="#" class="header__link">Pricing</a>
<a href="#" class="header__link">Changelog</a>
<a href="#" class="header__link">Templates</a>
<a href="#" class="header__link">Docs</a>
<a href="#" class="header__link">Discord</a>
</nav>
<div class="header__auth">
<button class="header__button header__button--create">Create Account</button>
<button class="header__button header__button--sign-in">Sign In</button>
</div>
</div>
</header>
<div class="container">
<h2 class="container__title">Any language, any framework, always secure</h2>
<p class="container__description">Integrate authentication into your APIs effortlessly with just a few lines of code. We offer SDKs for various languages and frameworks, alongside an intuitive REST API with a public OpenAPI specification.</p>
<div class="container__buttons">
<button class="container__button container__button--get-started">Get Started</button>
<button class="container__button container__button--view-docs"><span>Visit the docs </span><i class="fas fa-arrow-right"></i></button>
</div>
<div class="code-container-bg-blur"></div>
<div class="code-container">
<div class="code-container__tabs">
<button class="code-container__tab code-container__tab--active" data-language="typescript">
<i class="fab fa-js-square code-container__icon"></i>
Typescript
</button>
<button class="code-container__tab" data-language="python">
<i class="fab fa-python code-container__icon"></i>
Python
</button>
<button class="code-container__tab" data-language="rust">
<i class="fab fa-rust code-container__icon"></i>
Rust
</button>
<button class="code-container__tab" data-language="golang">
<i class="fab fa-google code-container__icon"></i>
Golang
</button>
<button class="code-container__tab" data-language="curl">
<i class="fas fa-terminal code-container__icon"></i>
Curl
</button>
<button class="code-container__tab" data-language="elixir">
<i class="fab fa-phoenix-framework code-container__icon"></i>
Elixir
</button>
<button class="code-container__tab" data-language="java">
<i class="fab fa-java code-container__icon"></i>
Java
</button>
</div>
<div class="code-container__content">
<div class="copy-icon" onclick="copyCode()" role="button" tabindex="0" aria-label="Copy code to clipboard" title="Copy code to clipboard">
<i class="fas fa-copy"></i>
</div>
<pre class="code-container__code code-container__code--typescript code-container__code--active line-numbers"><code class="language-typescript">import { verifyKey } from '@codeswitch/api'
const { result, error } = await verifyKey({
apiId: 'api_123',
key: 'xyz_123'
})
if (error) {
// handle network error
}
if (!result.valid) {
// reject unauthorized request
}
// handle request
</code></pre>
<pre class="code-container__code code-container__code--python line-numbers"><code class="language-python">import asyncio
import os
import codeswitch
async def main() -> None:
client = codeswitch.Client(api_key=os.environ["API_KEY"])
await client.start()
result = await client.keys.verify_key("prefix_abc123")
if result.is_ok {
print(data.valid);
} else {
print(result.unwrap_err());
}
</code></pre>
<pre class="code-container__code code-container__code--rust line-numbers"><code class="language-rust">use codeswitch::models::{VerifyKeyRequest, Wrapped};
use codeswitch::Client;
async fn verify_key() {
let api_key = env::var("codeswitch_API_KEY").expect("Environment variable CODESWITCH_API_KEY not found");
let c = Client::new(&api_key);
let req = VerifyKeyRequest::new("test_req", "api_458vdYdbwut5LWABzXZP3Z8jPVas");
match c.verify_key(req).await {
Wrapped::Ok(res) => println!("{{res:?}}"),
Wrapped::Err(err) => eprintln!("{{err:?}}"),
}
}
</code></pre>
<pre class="code-container__code code-container__code--golang line-numbers"><code class="language-go">package main
import (
"fmt"
codeswitch "github.com/WilfredAlmeida/codeswitch-go/features"
)
func main() {
apiKey := "key_3ZZ7faJrkfv1YAfhfAcnKW74";
response, err := codeswitch.KeyVerify(apiKey);
if err != nil {
fmt.Println("Error:", err);
return;
}
if response.Valid {
fmt.Println("Key is valid");
} else {
fmt.Println("Key is invalid");
}
}
</code></pre>
<pre class="code-container__code code-container__code--curl line-numbers"><code class="language-bash">curl --request POST \
--url https://api.codeswitch.dev/v1/keys.verifyKey \
--header 'Content-Type: application/json' \
--data '{
"apiId": "api_1234",
"key": "sk_1234",
}'
</code></pre>
<pre class="code-container__code code-container__code--elixir line-numbers"><code class="language-elixir">CodeswitchElixirSdk.verify_key("xyz_AS5HDbkXXPot2MMoPHD8jnL")
# returns
%{
"valid" => true,
"ownerId" => "chronak",
"meta" => %{
"hello" => "world"
}
}
</code></pre>
<pre class="code-container__code code-container__code--java line-numbers"><code class="language-java">package com.example.myapp;
import com.codeswitch.codeswitchsdk.dto.KeyVerifyRequest;
import com.codeswitch.codeswitchsdk.dto.KeyVerifyResponse;
@RestController
public class APIController {
private static IKeyService keyService = new KeyService();
@PostMapping("/verify")
public KeyVerifyResponse verifyKey(
@RequestBody KeyVerifyRequest keyVerifyRequest) {
// Delegate the creation of the key to the KeyService from the SDK
return keyService.verifyKey(keyVerifyRequest);
}
}
</code></pre>
</div>
</div>
</div>
<div class="open-source-section">
<h3 class="section-subtitle">oss/acc</h3>
<h2 class="section-title">Open-source</h2>
<p class="section-description">We believe strongly in the value of open source: our codebase and development process is available to learn from and contribute to.</p>
<button class="github-button"><i class="fab fa-github"></i> View on GitHub</button>
<div class="gitPulse">
<img src="images/gitpulse.svg" alt="GitPulse" />
<div class="gitPulse__bg"></div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<span>C</span>
<span>O</span>
<span>D</span>
<span>E</span>
<span>S</span>
<span>W</span>
<span>I</span>
<span>T</span>
<span>C</span>
<span>H</span>
</div>
</footer>
<script src="/script.js"></script>
<script src="/stars.js"></script>
<script>
document.querySelector('.mobile-menu-icon').addEventListener('click', function() {
document.querySelector('.header__nav').classList.toggle('active');
});
</script>
</body>
</html>