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
5 changes: 5 additions & 0 deletions .changeset/hungry-chairs-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/backend": patch
---

Add optional `secret` property in API key response
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/APIKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class APIKey {
readonly lastUsedAt: number | null,
readonly createdAt: number,
readonly updatedAt: number,
readonly secret?: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
readonly secret?: string,
readonly secret: string | null,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was kind of tricky since only the create method actually returns a secret property. The rest does not. So adding null I think is not ideal here 👀

We'll definitely improve this along the way

) {}

static fromJSON(data: APIKeyJSON) {
Expand All @@ -36,6 +37,7 @@ export class APIKey {
data.last_used_at,
data.created_at,
data.updated_at,
data.secret,
);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ export interface APIKeyJSON extends ClerkResourceJSON {
object: typeof ObjectType.ApiKey;
type: string;
name: string;
secret?: string;
subject: string;
scopes: string[];
claims: Record<string, any> | null;
Expand Down