File tree Expand file tree Collapse file tree
rivetkit-typescript/packages/rivetkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { RemoteEngineControlClient } from "@/engine-client/mod";
99import { ENGINE_ENDPOINT } from "@/common/engine" ;
1010import type { Registry } from "@/registry" ;
1111import type { RegistryActors , RegistryConfig } from "@/registry/config" ;
12- import { getNodeFsSync } from "@/utils/node" ;
12+ import { getNodeFsSync , importNodeDependencies } from "@/utils/node" ;
1313import pkg from "../package.json" with { type : "json" } ;
1414import { logger } from "../src/registry/log" ;
1515
@@ -149,6 +149,7 @@ export class Runtime<A extends RegistryActors> {
149149
150150 if ( this . #config. staticDir ) {
151151 try {
152+ importNodeDependencies ( ) ;
152153 const fsSync = getNodeFsSync ( ) ;
153154 if ( fsSync . existsSync ( this . #config. staticDir ) ) {
154155 logLine ( "Static" , `./${ this . #config. staticDir } ` ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import type {
1010 SqliteDatabase ,
1111} from "@/common/database/config" ;
1212import { toSqliteBindings } from "@/common/database/shared" ;
13- import { getNodeCrypto } from "@/utils/node " ;
13+ import { sha256Hex } from "@/utils/crypto " ;
1414
1515export type { SQLiteTable } from "drizzle-orm/sqlite-core" ;
1616export {
@@ -243,10 +243,7 @@ async function runMigrations<TSchema extends DrizzleSchema>(
243243
244244 await db . execute (
245245 "INSERT INTO __drizzle_migrations (hash, created_at) VALUES (?, ?)" ,
246- getNodeCrypto ( )
247- . createHash ( "sha256" )
248- . update ( migration )
249- . digest ( "hex" ) ,
246+ await sha256Hex ( migration ) ,
250247 entry . when ,
251248 ) ;
252249 }
Original file line number Diff line number Diff line change @@ -22,3 +22,17 @@ export function timingSafeEqual(
2222
2323 return result === 0 ;
2424}
25+
26+ export async function sha256Hex ( value : string ) : Promise < string > {
27+ if ( ! globalThis . crypto ?. subtle ) {
28+ throw new Error ( "Web Crypto API is required to compute SHA-256 hashes" ) ;
29+ }
30+
31+ const digest = await globalThis . crypto . subtle . digest (
32+ "SHA-256" ,
33+ new TextEncoder ( ) . encode ( value ) ,
34+ ) ;
35+ return Array . from ( new Uint8Array ( digest ) , ( byte ) =>
36+ byte . toString ( 16 ) . padStart ( 2 , "0" ) ,
37+ ) . join ( "" ) ;
38+ }
You can’t perform that action at this time.
0 commit comments