File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
packages/service-utils/src/core/authorize Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 66import { authorizeClient } from "./client.js" ;
77import { authorizeService } from "./service.js" ;
88import type { AuthorizationResult } from "./types.js" ;
9+ import { hashKey } from "./utils.js" ;
910
1011export type AuthorizationInput = {
1112 secretKey : string | null ;
@@ -41,7 +42,9 @@ export async function authorize(
4142 cacheOptions ?: CacheOptions ,
4243) : Promise < AuthorizationResult > {
4344 let teamAndProjectResponse : TeamAndProjectResponse | null = null ;
44- const cacheKey = `key_v2_${ authData . clientId ?? authData . secretKeyHash ?? authData . hashedJWT } ` ;
45+ const cacheKey = hashKey (
46+ `key_v2_:${ authData . secretKeyHash } :${ authData . hashedJWT } :${ authData . clientId } ` ,
47+ ) ;
4548 // TODO if we have cache options we want to check the cache first
4649 if ( cacheOptions ) {
4750 try {
Original file line number Diff line number Diff line change 1+ import crypto from "node:crypto" ;
2+
3+ export const hashKey = ( str : string ) : string => {
4+ return crypto . createHash ( "sha256" ) . update ( str , "utf8" ) . digest ( "hex" ) ;
5+ } ;
You can’t perform that action at this time.
0 commit comments