Skip to content

Commit d80f583

Browse files
committed
feat: add ecosystem heads to extractAuthorizationData
1 parent 0a1d59d commit d80f583

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.changeset/tame-tips-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
Adds ecosystem headers to extractAuthorizationData result

packages/service-utils/src/cf-worker/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ export async function extractAuthorizationData(
105105
bundleId = requestUrl.searchParams.get("bundleId");
106106
}
107107

108+
let ecosystemId = headers.get("x-ecosystem-id");
109+
if (!ecosystemId) {
110+
ecosystemId = requestUrl.searchParams.get("ecosystemId");
111+
}
112+
113+
let ecosystemPartnerId = headers.get("x-ecosystem-partner-id");
114+
if (!ecosystemPartnerId) {
115+
ecosystemPartnerId = requestUrl.searchParams.get("ecosystemPartnerId");
116+
}
117+
108118
let origin = headers.get("origin");
109119
// if origin header is not available we'll fall back to referrer;
110120
if (!origin) {
@@ -150,6 +160,8 @@ export async function extractAuthorizationData(
150160
hashedJWT: jwt ? await hashSecretKey(jwt) : null,
151161
secretKey,
152162
clientId,
163+
ecosystemId,
164+
ecosystemPartnerId,
153165
origin,
154166
bundleId,
155167
secretKeyHash,

packages/service-utils/src/core/authorize/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import type { AuthorizationResult } from "./types.js";
1212
export type AuthorizationInput = {
1313
secretKey: string | null;
1414
clientId: string | null;
15+
ecosystemId: string | null;
16+
ecosystemPartnerId: string | null;
1517
origin: string | null;
1618
bundleId: string | null;
1719
secretKeyHash: string | null;

packages/service-utils/src/node/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function extractAuthorizationData(
107107
if (!clientId) {
108108
clientId = requestUrl.searchParams.get("clientId");
109109
}
110+
110111
// bundle id from header is first preference
111112
let bundleId = getHeader(headers, "x-bundle-id");
112113

@@ -115,6 +116,16 @@ export function extractAuthorizationData(
115116
bundleId = requestUrl.searchParams.get("bundleId");
116117
}
117118

119+
let ecosystemId = getHeader(headers, "x-ecosystem-id");
120+
if (!ecosystemId) {
121+
ecosystemId = requestUrl.searchParams.get("ecosystemId");
122+
}
123+
124+
let ecosystemPartnerId = getHeader(headers, "x-ecosystem-partner-id");
125+
if (!ecosystemPartnerId) {
126+
ecosystemPartnerId = requestUrl.searchParams.get("ecosystemPartnerId");
127+
}
128+
118129
let origin = getHeader(headers, "origin");
119130
// if origin header is not available we'll fall back to referrer;
120131
if (!origin) {
@@ -166,6 +177,8 @@ export function extractAuthorizationData(
166177
secretKeyHash,
167178
secretKey,
168179
clientId,
180+
ecosystemId,
181+
ecosystemPartnerId,
169182
origin,
170183
bundleId,
171184
targetAddress: authInput.targetAddress,

0 commit comments

Comments
 (0)