Skip to content

Commit 67f63c3

Browse files
committed
remove client ID derivation from secret key (#5729)
fixes: DASH-621 we explicitly *DO NOT* want to derive from secretKey anymore - this would otherwise block multi secret key per project
1 parent a077023 commit 67f63c3

File tree

3 files changed

+0
-42
lines changed

3 files changed

+0
-42
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,6 @@ export async function extractAuthorizationData(
129129
if (secretKey) {
130130
// hash the secret key
131131
secretKeyHash = await hashSecretKey(secretKey);
132-
// derive the client id from the secret key hash
133-
const derivedClientId = deriveClientIdFromSecretKeyHash(secretKeyHash);
134-
// if we already have a client id passed in we need to make sure they match
135-
if (clientId && clientId !== derivedClientId) {
136-
throw new Error("KEY_CONFLICT");
137-
}
138-
// otherwise set the client id to the derived client id (client id based off of secret key)
139-
clientId = derivedClientId;
140132
}
141133

142134
let jwt: string | null = null;
@@ -170,10 +162,6 @@ export async function hashSecretKey(secretKey: string) {
170162
);
171163
}
172164

173-
export function deriveClientIdFromSecretKeyHash(secretKeyHash: string) {
174-
return secretKeyHash.slice(0, 32);
175-
}
176-
177165
function bufferToHex(buffer: ArrayBuffer) {
178166
return [...new Uint8Array(buffer)]
179167
.map((x) => x.toString(16).padStart(2, "0"))

packages/service-utils/src/core/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export type CoreServiceConfig = {
2222
serviceApiKey: string;
2323
serviceAction?: string;
2424
useWalletAuth?: boolean;
25-
includeUsage?: boolean;
2625
};
2726

2827
export type TeamAndProjectResponse = {

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ export type AuthInput = CoreAuthInput & {
2121
req: IncomingMessage | Request;
2222
};
2323

24-
/**
25-
*
26-
* @param {AuthInput['req']} authInput.req - The incoming request from which information will be pulled from. These information includes (checks are in order and terminates on first match):
27-
* - clientId: Checks header `x-client-id`, search param `clientId`
28-
* - bundleId: Checks header `x-bundle-id`, search param `bundleId`
29-
* - secretKey: Checks header `x-secret-key`
30-
* - origin (the requesting domain): Checks header `origin`, `referer`
31-
* @param {AuthInput['clientId']} authInput.clientId - Overrides any clientId found on the `req` object
32-
* @param {AuthInput['targetAddress']} authInput.targetAddress - Only used in smart wallets to determine if the request is authorized to interact with the target address.
33-
* @param {NodeServiceConfig['enforceAuth']} serviceConfig - Always `true` unless you need to turn auth off. Tells the service whether or not to enforce auth.
34-
* @param {NodeServiceConfig['apiUrl']} serviceConfig.apiUrl - The url of the api server to fetch information for verification. `https://api.thirdweb.com` for production and `https://api.staging.thirdweb.com` for staging
35-
* @param {NodeServiceConfig['serviceApiKey']} serviceConfig.serviceApiKey - secret key to be used authenticate the caller of the api-server. Check the api-server's env variable for the keys.
36-
* @param {NodeServiceConfig['serviceScope']} serviceConfig.serviceScope - The service that we are requesting authorization for. E.g. `relayer`, `rpc`, 'bundler', 'storage' etc.
37-
* @param {NodeServiceConfig['serviceAction']} serviceConfig.serviceAction - Needed when the `serviceScope` is `storage`. Can be either `read` or `write`.
38-
* @param {NodeServiceConfig['useWalletAuth']} serviceConfig.useWalletAuth - If true it pings the `wallet/me` or else, `account/me`. You most likely can leave this as false.
39-
* @returns {AuthorizationResult} authorizationResult - contains if the request is authorized, and information about the account if it is authorized. Otherwise, it contains the error message and status code.
40-
*/
4124
export async function authorizeNode(
4225
authInput: AuthInput,
4326
serviceConfig: NodeServiceConfig,
@@ -150,14 +133,6 @@ export function extractAuthorizationData(
150133
if (secretKey) {
151134
// hash the secret key
152135
secretKeyHash = hashSecretKey(secretKey);
153-
// derive the client id from the secret key hash
154-
const derivedClientId = deriveClientIdFromSecretKeyHash(secretKeyHash);
155-
// if we already have a client id passed in we need to make sure they match
156-
if (clientId && clientId !== derivedClientId) {
157-
throw new Error("KEY_CONFLICT");
158-
}
159-
// otherwise set the client id to the derived client id (client id based off of secret key)
160-
clientId = derivedClientId;
161136
}
162137

163138
let jwt: null | string = null;
@@ -195,10 +170,6 @@ export function hashSecretKey(secretKey: string) {
195170
return createHash("sha256").update(secretKey).digest("hex");
196171
}
197172

198-
export function deriveClientIdFromSecretKeyHash(secretKeyHash: string) {
199-
return secretKeyHash.slice(0, 32);
200-
}
201-
202173
export function logHttpRequest({
203174
clientId,
204175
req,

0 commit comments

Comments
 (0)