Skip to content

Open-source status page, incident response and uptime monitoring

chore: bump unkey (#1138)

Maximilian Kaske917979bb93da
diff --git a/apps/server/package.json b/apps/server/package.json
index 9d7f2bee4..263df5984 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -28,7 +28,7 @@
"@openstatus/utils": "workspace:*",
"@scalar/hono-api-reference": "0.5.131",
"@t3-oss/env-core": "0.7.1",
- "@unkey/api": "0.23.0",
+ "@unkey/api": "0.26.1",
"@upstash/qstash": "2.6.2",
"hono": "4.5.3",
"nanoid": "5.0.7",
diff --git a/apps/web/package.json b/apps/web/package.json
index 9a8596b7d..14202e4a0 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -45,7 +45,7 @@
"@trpc/next": "11.0.0-rc.666",
"@trpc/react-query": "11.0.0-rc.666",
"@trpc/server": "11.0.0-rc.666",
- "@unkey/api": "0.23.0",
+ "@unkey/api": "0.26.1",
"@upstash/qstash": "2.6.2",
"@upstash/redis": "1.22.1",
"@vercel/blob": "0.23.3",
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/actions.ts b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/actions.ts
index d3086154a..173f42f55 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/actions.ts
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/actions.ts
@@ -7,6 +7,7 @@ import { user, usersToWorkspaces, workspace } from "@openstatus/db/src/schema";
import { env } from "@/env";
import { auth } from "@/lib/auth";
+import { revalidatePath } from "next/cache";
const unkey = new Unkey({ token: env.UNKEY_TOKEN, cache: "no-cache" });
@@ -34,10 +35,16 @@ export async function create(ownerId: number) {
ownerId: String(ownerId),
prefix: "os",
});
+
+ revalidatePath("/app/[workspaceSlug]/(dashboard)/settings/api-token");
+
return key;
}
export async function revoke(keyId: string) {
const res = await unkey.keys.delete({ keyId });
+
+ revalidatePath("/app/[workspaceSlug]/(dashboard)/settings/api-token");
+
return res;
}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/card.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/card.tsx
index ec99a1754..cc55fb501 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/card.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/_components/card.tsx
@@ -1,27 +1,15 @@
-"use server";
-
-import { Unkey } from "@unkey/api";
-
import { Container } from "@/components/dashboard/container";
-import { env } from "@/env";
import { formatDate } from "@/lib/utils";
import { CreateForm } from "./create-form";
import { RevokeButton } from "./revoke-button";
-const unkey = new Unkey({ token: env.UNKEY_TOKEN });
-
-export async function ApiKeys({ ownerId }: { ownerId: number }) {
- const data = await unkey.apis.listKeys({
- apiId: env.UNKEY_API_ID,
- ownerId: String(ownerId),
- });
-
- if (data.error) {
- return <div>Something went wrong. Please contact us.</div>;
- }
-
- const key = data.result.keys?.[0] || undefined;
-
+export async function ApiKeys({
+ ownerId,
+ value,
+}: {
+ ownerId: number;
+ value?: { id: string; start: string; createdAt: number };
+}) {
return (
<>
<Container
@@ -29,32 +17,34 @@ export async function ApiKeys({ ownerId }: { ownerId: number }) {
description="Use our API endpoints to create your monitors programmatically."
actions={
<>
- {key ? (
- <RevokeButton keyId={key.id} />
+ {value ? (
+ <RevokeButton keyId={value.id} />
) : (
<CreateForm ownerId={ownerId} />
)}
</>
}
>
- {key ? (
+ {value ? (
<dl className="grid gap-2 [&>*]:text-sm [&_dt]:font-light [&_dt]:text-muted-foreground">
<div className="flex min-w-0 items-center justify-between gap-3">
<dt>Token</dt>
- <dd className="font-mono">{key.start}...</dd>
+ <dd className="font-mono">{value.start}...</dd>
</div>
<div className="flex min-w-0 items-center justify-between gap-3">
<dt>Created At</dt>
- <dd>{key.createdAt && formatDate(new Date(key.createdAt))}</dd>
+ <dd>
+ {value.createdAt && formatDate(new Date(value.createdAt))}
+ </dd>
</div>
</dl>
) : null}
</Container>
<p className="text-foreground text-sm">
- Read more about APIs in our{" "}
+ Read more about API in our{" "}
<a
className="text-foreground underline underline-offset-4 hover:no-underline"
- href="https://docs.openstatus.dev/api-reference/auth"
+ href="https://api.openstatus.dev/v1"
target="_blank"
rel="noreferrer"
>
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/page.tsx
index b3e2d664d..998801e83 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/api-token/page.tsx
@@ -1,8 +1,26 @@
+import { Unkey } from "@unkey/api";
+
+import { env } from "@/env";
import { api } from "@/trpc/server";
import { ApiKeys } from "./_components/card";
+export const revalidate = 0;
+
+const unkey = new Unkey({ token: env.UNKEY_TOKEN, cache: "no-cache" });
+
export default async function ApiTokenPage() {
- const data = await api.workspace.getWorkspace.query();
+ const workspace = await api.workspace.getWorkspace.query();
+
+ const data = await unkey.apis.listKeys({
+ apiId: env.UNKEY_API_ID,
+ ownerId: String(workspace.id),
+ });
+
+ if (data.error) {
+ return <div>Something went wrong. Please contact us.</div>;
+ }
+
+ const value = data.result.keys?.[0] || undefined;
- return <ApiKeys ownerId={data.id} />;
+ return <ApiKeys ownerId={workspace.id} value={value} />;
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 79ec42e21..884c0817e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -167,8 +167,8 @@ importers:
specifier: 0.7.1
'@unkey/api':
- specifier: 0.23.0
- version: 0.23.0
+ specifier: 0.26.1
+ version: 0.26.1
'@upstash/qstash':
specifier: 2.6.2
version: 2.6.2
@@ -309,8 +309,8 @@ importers:
specifier: 11.0.0-rc.666
version: 11.0.0-rc.666([email protected])
'@unkey/api':
- specifier: 0.23.0
- version: 0.23.0
+ specifier: 0.26.1
+ version: 0.26.1
'@upstash/qstash':
specifier: 2.6.2
version: 2.6.2
@@ -5129,8 +5129,8 @@ packages:
peerDependencies:
vue: '>=2.7 || >=3'
- '@unkey/[email protected]':
- resolution: {integrity: sha512-N4mFiIQdzBaqDGtBZ70y8d7rNeRgi2iEWac7BgTsiflx12BfMHWd4oMglmUJ4uqHNmNqm3yNVSih7BY24H5K8g==}
+ '@unkey/[email protected]':
+ resolution: {integrity: sha512-WSYOeZjGbFkO9yA4UsNS6NjprUF9OAYIlBHN/7iRUaFBq+PL502Qe10xNwiwoppYhW6PnrCFobW92vrkjHTcjA==}
resolution: {integrity: sha512-DFGb4A7SrusZPP0FYuRIF0CO+Gi4etLUAEJ6EKc+TKYmscL0nEJ2Pr38FyX9MvjI4Wx5l35Wc9KsBjMm9Ybh7w==}
@@ -14987,7 +14987,7 @@ snapshots:
unhead: 1.9.15
vue: 3.4.31([email protected])
- '@unkey/[email protected]':
+ '@unkey/[email protected]':
dependencies:
'@unkey/rbac': 0.3.1