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 6
6
import { authorizeClient } from "./client.js" ;
7
7
import { authorizeService } from "./service.js" ;
8
8
import type { AuthorizationResult } from "./types.js" ;
9
+ import { hashKey } from "./utils.js" ;
9
10
10
11
export type AuthorizationInput = {
11
12
secretKey : string | null ;
@@ -41,7 +42,9 @@ export async function authorize(
41
42
cacheOptions ?: CacheOptions ,
42
43
) : Promise < AuthorizationResult > {
43
44
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
+ ) ;
45
48
// TODO if we have cache options we want to check the cache first
46
49
if ( cacheOptions ) {
47
50
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