Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/api/src/routes/v1_keys_updateKey.error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ test("when the key has been deleted", async (t) => {
start: "test",
name: "test",
hash: await sha256(new KeyV1({ byteLength: 16 }).toString()),
createdAt: new Date(),
deletedAt: new Date(),
createdAtM: Date.now(),
deletedAtM: Date.now(),
};
await h.db.primary.insert(schema.keys).values(key);

Expand All @@ -106,7 +106,7 @@ test("when the key has been deleted", async (t) => {
enabled: false,
},
});
expect(res.status).toEqual(404);
expect(res.status, `Expected 404, got: ${JSON.stringify(res)}`).toEqual(404);
expect(res.body).toMatchObject({
error: {
code: "NOT_FOUND",
Expand Down
28 changes: 28 additions & 0 deletions apps/api/src/routes/v1_keys_verifyKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ test("returns 200", async (t) => {
expect(res.body.valid).toBe(true);
});

test("returns a requestId", async (t) => {
const h = await IntegrationHarness.init(t);

const key = new KeyV1({ prefix: "test", byteLength: 16 }).toString();
await h.db.primary.insert(schema.keys).values({
id: newId("test"),
keyAuthId: h.resources.userKeyAuth.id,
hash: await sha256(key),
start: key.slice(0, 8),
workspaceId: h.resources.userWorkspace.id,
createdAtM: Date.now(),
});

const res = await h.post<V1KeysVerifyKeyRequest, V1KeysVerifyKeyResponse>({
url: "/v1/keys.verifyKey",
headers: {
"Content-Type": "application/json",
},
body: {
key,
apiId: h.resources.userApi.id,
},
});

expect(res.status, `expected 200, received: ${JSON.stringify(res, null, 2)}`).toBe(200);
expect(res.body.requestId).toBeDefined();
});

describe("bad request", () => {
test("returns 400", async (t) => {
const h = await IntegrationHarness.init(t);
Expand Down
6 changes: 6 additions & 0 deletions apps/api/src/routes/v1_keys_verifyKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ These are validation codes, the HTTP status will be 200.
.openapi({
description: "The associated identity of this key.",
}),
requestId: z.string().openapi({
description:
"A unique id for this request, please provide it to Unkey support to help us debug your issue.",
}),
})
.openapi("V1KeysVerifyKeyResponse"),
},
Expand Down Expand Up @@ -354,6 +358,7 @@ export const registerV1KeysVerifyKey = (app: App) =>
return c.json({
valid: false,
code: val.code,
requestId: c.get("requestId"),
});
}

Expand All @@ -377,6 +382,7 @@ export const registerV1KeysVerifyKey = (app: App) =>
meta: val.identity.meta ?? {},
}
: undefined,
requestId: c.get("requestId"),
};
c.executionCtx.waitUntil(
analytics
Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/routes/v1_migrations_createKey.happy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ describe("roles", () => {

const root = await h.createRootKey([`api.${h.resources.userApi.id}.create_key`]);

const plaintext = crypto.randomUUID();

const res = await h.post<V1MigrationsCreateKeysRequest, V1MigrationsCreateKeysResponse>({
url: "/v1/migrations.createKeys",
headers: {
Expand All @@ -301,7 +303,7 @@ describe("roles", () => {
body: [
{
start: "start_",
plaintext: "plaintext",
plaintext,
apiId: h.resources.userApi.id,
permissions,
},
Expand Down
3 changes: 1 addition & 2 deletions apps/www/app/careers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export default async function Careers() {
<div className="mx-auto flex-flex-col ">
<h2 className="blog-heading-gradient text-6xl font-medium mt-12">Open Positions</h2>
<p className="mt-6 font-normal leading-7 text-balance">
Unkey is 100% remote. We currently live in Germany, Turkey and the United
States.
Unkey is 100% remote. We currently live in Germany, Turkey and the United States.
</p>
</div>
</div>
Expand Down
Loading