Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add `webhooks.*` scopes to create API modal

Kiran K126819021ca6
diff --git a/apps/web/lib/api/rbac/resources.ts b/apps/web/lib/api/rbac/resources.ts
index 5b4d576a1f..5240c7b139 100644
--- a/apps/web/lib/api/rbac/resources.ts
+++ b/apps/web/lib/api/rbac/resources.ts
@@ -6,10 +6,9 @@ export const RESOURCE_KEYS = [
"tags",
"tokens",
"conversions",
+ "webhooks",
] as const;
-export type ResourceKey = (typeof RESOURCE_KEYS)[number];
-
export const RESOURCES: {
name: string;
key: ResourceKey;
@@ -52,4 +51,12 @@ export const RESOURCES: {
description: "Track conversions (customer, lead, sales)",
betaFeature: true,
},
+ {
+ name: "Webhooks",
+ key: "webhooks",
+ description: "Create, read, update, and delete webhooks",
+ betaFeature: true,
+ },
];
+
+export type ResourceKey = (typeof RESOURCE_KEYS)[number];
diff --git a/apps/web/lib/api/tokens/scopes.ts b/apps/web/lib/api/tokens/scopes.ts
index ce8cb5c5c8..9d9568256b 100644
--- a/apps/web/lib/api/tokens/scopes.ts
+++ b/apps/web/lib/api/tokens/scopes.ts
@@ -13,6 +13,8 @@ export const SCOPES = [
"domains.read",
"domains.write",
"conversions.write",
+ "webhooks.read",
+ "webhooks.write",
"apis.all", // All API scopes
"apis.read", // All read scopes
] as const;
@@ -97,6 +99,20 @@ export const RESOURCE_SCOPES: {
type: "write",
resource: "conversions",
},
+ {
+ scope: "webhooks.read",
+ roles: ["owner", "member"],
+ permissions: ["webhooks.read"],
+ type: "read",
+ resource: "webhooks",
+ },
+ {
+ scope: "webhooks.write",
+ roles: ["owner"],
+ permissions: ["webhooks.write", "webhooks.read"],
+ type: "write",
+ resource: "webhooks",
+ },
{
scope: "apis.read",
roles: ["owner", "member"],
@@ -106,6 +122,7 @@ export const RESOURCE_SCOPES: {
"domains.read",
"workspaces.read",
"analytics.read",
+ "webhooks.read",
],
},
{
@@ -122,6 +139,8 @@ export const RESOURCE_SCOPES: {
"workspaces.write",
"analytics.read",
"conversions.write",
+ "webhooks.read",
+ "webhooks.write",
],
},
];