@@ -15,14 +15,10 @@ import {
15
15
CardHeader ,
16
16
CardTitle ,
17
17
Checkbox ,
18
- Code ,
19
- CopyButton ,
20
- InfoTooltip ,
21
18
Input ,
22
- VisibleButton ,
23
19
toast ,
24
20
} from "@unkey/ui" ;
25
- import { ArrowRight , ChevronRight } from "lucide-react" ;
21
+ import { ChevronRight } from "lucide-react" ;
26
22
import { useRouter } from "next/navigation" ;
27
23
import { createParser , parseAsArrayOf , useQueryState } from "nuqs" ;
28
24
import { useEffect , useRef , useState } from "react" ;
@@ -74,13 +70,10 @@ const parseAsUnkeyPermission = createParser({
74
70
serialize : String ,
75
71
} ) ;
76
72
77
- const UNNAMED_KEY = "Unnamed Key" ;
78
-
79
73
export const Client : React . FC < Props > = ( { apis } ) => {
80
74
const trpcUtils = trpc . useUtils ( ) ;
81
75
const router = useRouter ( ) ;
82
76
const [ name , setName ] = useState < string | undefined > ( undefined ) ;
83
- const [ showKeyInSnippet , setShowKeyInSnippet ] = useState ( false ) ;
84
77
const [ isConfirmOpen , setIsConfirmOpen ] = useState ( false ) ;
85
78
const [ pendingAction , setPendingAction ] = useState <
86
79
"close" | "create-another" | "go-to-details" | null
@@ -106,22 +99,6 @@ export const Client: React.FC<Props> = ({ apis }) => {
106
99
} ,
107
100
} ) ;
108
101
109
- const snippet = `curl -XPOST '${
110
- process . env . NEXT_PUBLIC_UNKEY_API_URL ?? "https://api.unkey.dev"
111
- } /v1/keys.createKey' \\
112
- -H 'Authorization: Bearer ${ key . data ?. key } ' \\
113
- -H 'Content-Type: application/json' \\
114
- -d '{
115
- "prefix": "hello",
116
- "apiId": "<API_ID>"
117
- }'` ;
118
-
119
- const split = key . data ?. key ?. split ( "_" ) ?? [ ] ;
120
- const maskedKey =
121
- split . length >= 2
122
- ? `${ split . at ( 0 ) } _${ "*" . repeat ( split . at ( 1 ) ?. length ?? 0 ) } `
123
- : "*" . repeat ( split . at ( 0 ) ?. length ?? 0 ) ;
124
-
125
102
const handleSetChecked = ( permission : UnkeyPermission , checked : boolean ) => {
126
103
setSelectedPermissions ( ( prevPermissions ) => {
127
104
const permissionSet = new Set ( prevPermissions ) ;
@@ -411,39 +388,9 @@ export const Client: React.FC<Props> = ({ apis }) => {
411
388
< div className = "p-1 w-full my-8" >
412
389
< div className = "h-[1px] bg-grayA-3 w-full" />
413
390
</ div >
391
+
414
392
< div className = "flex flex-col gap-2 items-start w-full" >
415
- < div className = "text-gray-12 text-sm font-semibold" > Key Details</ div >
416
- < div className = "bg-white dark:bg-black border rounded-xl border-grayA-5 px-6 w-full" >
417
- < div className = "flex gap-6 items-center" >
418
- < div className = "bg-grayA-5 text-gray-12 size-5 flex items-center justify-center rounded " >
419
- < Key2 size = "sm-regular" />
420
- </ div >
421
- < div className = "flex flex-col gap-1 py-6" >
422
- < div className = "text-accent-12 text-xs font-mono" > { key . data ?. keyId } </ div >
423
- < InfoTooltip
424
- content = { name ?? UNNAMED_KEY }
425
- position = { { side : "bottom" , align : "center" } }
426
- asChild
427
- disabled = { ! name }
428
- variant = "inverted"
429
- >
430
- < div className = "text-accent-9 text-xs max-w-[160px] truncate" >
431
- { name ?? UNNAMED_KEY }
432
- </ div >
433
- </ InfoTooltip >
434
- </ div >
435
- < Button
436
- variant = "outline"
437
- className = "ml-auto font-medium text-[13px] text-gray-12"
438
- onClick = { ( ) => handleCloseAttempt ( "go-to-details" ) }
439
- >
440
- See key details < ArrowRight size = "sm-regular" />
441
- </ Button >
442
- </ div >
443
- </ div >
444
- </ div >
445
- < div className = "flex flex-col gap-2 items-start w-full mt-6" >
446
- < div className = "text-gray-12 text-sm font-semibold" > Key Secret</ div >
393
+ < div className = "text-gray-12 text-sm font-semibold" > Root Key</ div >
447
394
< SecretKey
448
395
value = { key . data ?. key ?? "" }
449
396
title = "API Key"
@@ -452,7 +399,7 @@ export const Client: React.FC<Props> = ({ apis }) => {
452
399
< div className = "text-gray-9 text-[13px] flex items-center gap-1.5" >
453
400
< CircleInfo className = "text-accent-9" size = "sm-regular" />
454
401
< span >
455
- Copy and save this key secret as it won't be shown again.{ " " }
402
+ Copy and save this secret as it won't be shown again.{ " " }
456
403
< a
457
404
href = "https://www.unkey.com/docs/security/recovering-keys"
458
405
target = "_blank"
@@ -464,23 +411,9 @@ export const Client: React.FC<Props> = ({ apis }) => {
464
411
</ span >
465
412
</ div >
466
413
</ div >
467
- < div className = "flex flex-col gap-2 items-start w-full mt-8" >
468
- < div className = "text-gray-12 text-sm font-semibold" > Try It Out</ div >
469
- < Code
470
- visibleButton = {
471
- < VisibleButton
472
- isVisible = { showKeyInSnippet }
473
- setIsVisible = { setShowKeyInSnippet }
474
- />
475
- }
476
- copyButton = { < CopyButton value = { snippet } /> }
477
- >
478
- { showKeyInSnippet ? snippet : snippet . replace ( key . data ?. key ?? "" , maskedKey ) }
479
- </ Code >
480
- </ div >
481
414
< div className = "mt-6" >
482
415
< div className = "mt-4 text-center text-gray-10 text-xs leading-6" >
483
- All set! You can now create another key or explore the docs to learn more
416
+ All set! You can now create another root key or explore the docs to learn more
484
417
</ div >
485
418
</ div >
486
419
</ div >
0 commit comments