diff --git a/jsmod.go b/jsmod.go index 2b95128..2176442 100644 --- a/jsmod.go +++ b/jsmod.go @@ -1,6 +1,22 @@ package jsmod -import "sync" +import ( + "context" + "sync" +) + +type contextKey string + +const SafeModeKey contextKey = "SafeMode" + +// IsSafeMode checks if the provided context indicates that the execution is in safe mode. +func IsSafeMode(ctx context.Context) bool { + v := ctx.Value(SafeModeKey) + if sm, ok := v.(bool); ok { + return sm + } + return false // Default to false if not specified (internal trusted caller) +} type Module struct { Exports map[string]any