File tree Expand file tree Collapse file tree
packages/connectivity/src/scp-cf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { createHash } from 'node:crypto' ;
1+ import * as crypto from 'node:crypto' ;
22import { stringify } from 'safe-stable-stringify' ;
33
44interface CacheInterface < T > {
@@ -164,7 +164,14 @@ export class Cache<T> implements CacheInterface<T> {
164164 */
165165export function hashCacheKey ( value : Record < string , unknown > ) : string {
166166 const serialized = stringify ( value ) ;
167- return createHash ( 'blake2s256' ) . update ( serialized ) . digest ( 'hex' ) ;
167+
168+ // TODO: crypto.hash is available in Node.js v20.12.0 and later.
169+ // Remove the fallback to crypto.createHash once Node.js 22 is the minimum supported version.
170+ if ( typeof crypto . hash === 'function' ) {
171+ return crypto . hash ( 'blake2s256' , serialized , 'base64url' ) ;
172+ }
173+
174+ return crypto . createHash ( 'blake2s256' ) . update ( serialized ) . digest ( 'base64url' ) ;
168175}
169176
170177function isExpired < T > ( item : CacheEntry < T > ) : boolean {
You can’t perform that action at this time.
0 commit comments