@@ -16,11 +16,24 @@ import type {
1616 ListViewsResponse ,
1717 SavedView
1818} from '@objectstack/spec/api' ;
19- import { createHash } from 'crypto' ;
2019
2120// We import SchemaRegistry directly since this class lives in the same package
2221import { SchemaRegistry } from './registry' ;
2322
23+ /**
24+ * Simple hash function for ETag generation (browser-compatible)
25+ * Uses a basic hash algorithm instead of crypto.createHash
26+ */
27+ function simpleHash ( str : string ) : string {
28+ let hash = 0 ;
29+ for ( let i = 0 ; i < str . length ; i ++ ) {
30+ const char = str . charCodeAt ( i ) ;
31+ hash = ( ( hash << 5 ) - hash ) + char ;
32+ hash = hash & hash ; // Convert to 32bit integer
33+ }
34+ return Math . abs ( hash ) . toString ( 16 ) ;
35+ }
36+
2437export class ObjectStackProtocolImplementation implements IObjectStackProtocol {
2538 private engine : IDataEngine ;
2639 private viewStorage : Map < string , SavedView > = new Map ( ) ;
@@ -131,9 +144,9 @@ export class ObjectStackProtocolImplementation implements IObjectStackProtocol {
131144 throw new Error ( `Metadata item ${ type } /${ name } not found` ) ;
132145 }
133146
134- // Calculate ETag (MD5 hash of the stringified metadata)
147+ // Calculate ETag (simple hash of the stringified metadata)
135148 const content = JSON . stringify ( item ) ;
136- const hash = createHash ( 'md5' ) . update ( content ) . digest ( 'hex' ) ;
149+ const hash = simpleHash ( content ) ;
137150 const etag = { value : hash , weak : false } ;
138151
139152 // Check If-None-Match header
0 commit comments