@luckylillia-dev/plugin-aiimgdetector 0.0.0-placeholder → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +2 -2
  2. package/assets/demo.png +0 -0
  3. package/assets/icon.svg +15 -0
  4. package/assets/synthid-login-check.jpg +0 -0
  5. package/docs/details.md +45 -0
  6. package/docs/publishing.md +66 -0
  7. package/docs/synthid.md +80 -0
  8. package/lib/image.js +90 -0
  9. package/lib/index.js +207 -0
  10. package/lib/provenance.js +21 -0
  11. package/lib/synthid-auth.js +100 -0
  12. package/lib/synthid-browser.js +451 -0
  13. package/lib/synthid-http-runtime/chromium-css-property-catalog.mjs +7 -0
  14. package/lib/synthid-http-runtime/complete-protocol.mjs +88 -0
  15. package/lib/synthid-http-runtime/entry.d.mts +41 -0
  16. package/lib/synthid-http-runtime/entry.mjs +6 -0
  17. package/lib/synthid-http-runtime/event-listener-diagnostics.mjs +141 -0
  18. package/lib/synthid-http-runtime/independent-request-reference.mjs +49 -0
  19. package/lib/synthid-http-runtime/jsdom-event-clock-compat.mjs +76 -0
  20. package/lib/synthid-http-runtime/lifecycle-client.mjs +165 -0
  21. package/lib/synthid-http-runtime/lifecycle-web-session.mjs +114 -0
  22. package/lib/synthid-http-runtime/lifecycle-worker.mjs +363 -0
  23. package/lib/synthid-http-runtime/node-platform-failure-diagnostics.mjs +108 -0
  24. package/lib/synthid-http-runtime/realm-activation-diagnostic.js +31 -0
  25. package/lib/synthid-http-runtime/realm-focus-diagnostic.js +9 -0
  26. package/lib/synthid-http-runtime/realm-init.js +34 -0
  27. package/lib/synthid-http-runtime/realm-pointer-diagnostic.js +49 -0
  28. package/lib/synthid-http-runtime/runtime-anchor-href-translate.mjs +242 -0
  29. package/lib/synthid-http-runtime/runtime-child-web-compat.mjs +103 -0
  30. package/lib/synthid-http-runtime/runtime-chrome-csi.mjs +216 -0
  31. package/lib/synthid-http-runtime/runtime-clock-precision-control.mjs +51 -0
  32. package/lib/synthid-http-runtime/runtime-css-properties-compat.mjs +165 -0
  33. package/lib/synthid-http-runtime/runtime-detached-frame-compat.mjs +214 -0
  34. package/lib/synthid-http-runtime/runtime-javascript-bindings.mjs +69 -0
  35. package/lib/synthid-http-runtime/runtime-navigator-compat.mjs +99 -0
  36. package/lib/synthid-http-runtime/runtime-permissions-binding.mjs +64 -0
  37. package/lib/synthid-http-runtime/runtime-permissions-control.mjs +143 -0
  38. package/lib/synthid-http-runtime/runtime-web-compat.mjs +639 -0
  39. package/lib/synthid-http-runtime/runtime-webidl-callable-control.mjs +151 -0
  40. package/lib/synthid-http-runtime/runtime-webidl-realm-compat.mjs +132 -0
  41. package/lib/synthid-http-runtime/runtime-window-state-compat.mjs +128 -0
  42. package/lib/synthid-http-runtime/scripting-parser.mjs +13 -0
  43. package/lib/synthid-http-runtime/web-session.mjs +64 -0
  44. package/lib/synthid-http-runtime/webidl-brand-errors-preload.mjs +49 -0
  45. package/lib/synthid-http-runtime/webidl-callable-source-catalog.mjs +4491 -0
  46. package/lib/synthid-http-runtime/webidl-realm-catalog.mjs +124 -0
  47. package/lib/synthid-http.js +314 -0
  48. package/lib/synthid-manual.js +365 -0
  49. package/lib/synthid-page.js +101 -0
  50. package/lib/synthid-result.js +189 -0
  51. package/lib/synthid.js +540 -0
  52. package/lib/vision.js +41 -0
  53. package/package.json +77 -4
  54. package/src/image.ts +74 -0
  55. package/src/index.ts +203 -0
  56. package/src/provenance.ts +40 -0
  57. package/src/synthid-auth.ts +83 -0
  58. package/src/synthid-browser.ts +426 -0
  59. package/src/synthid-http-runtime/chromium-css-property-catalog.mjs +7 -0
  60. package/src/synthid-http-runtime/complete-protocol.mjs +88 -0
  61. package/src/synthid-http-runtime/entry.d.mts +41 -0
  62. package/src/synthid-http-runtime/entry.mjs +6 -0
  63. package/src/synthid-http-runtime/event-listener-diagnostics.mjs +141 -0
  64. package/src/synthid-http-runtime/independent-request-reference.mjs +49 -0
  65. package/src/synthid-http-runtime/jsdom-event-clock-compat.mjs +76 -0
  66. package/src/synthid-http-runtime/lifecycle-client.mjs +165 -0
  67. package/src/synthid-http-runtime/lifecycle-web-session.mjs +114 -0
  68. package/src/synthid-http-runtime/lifecycle-worker.mjs +363 -0
  69. package/src/synthid-http-runtime/node-platform-failure-diagnostics.mjs +108 -0
  70. package/src/synthid-http-runtime/realm-activation-diagnostic.js +31 -0
  71. package/src/synthid-http-runtime/realm-focus-diagnostic.js +9 -0
  72. package/src/synthid-http-runtime/realm-init.js +34 -0
  73. package/src/synthid-http-runtime/realm-pointer-diagnostic.js +49 -0
  74. package/src/synthid-http-runtime/runtime-anchor-href-translate.mjs +242 -0
  75. package/src/synthid-http-runtime/runtime-child-web-compat.mjs +103 -0
  76. package/src/synthid-http-runtime/runtime-chrome-csi.mjs +216 -0
  77. package/src/synthid-http-runtime/runtime-clock-precision-control.mjs +51 -0
  78. package/src/synthid-http-runtime/runtime-css-properties-compat.mjs +165 -0
  79. package/src/synthid-http-runtime/runtime-detached-frame-compat.mjs +214 -0
  80. package/src/synthid-http-runtime/runtime-javascript-bindings.mjs +69 -0
  81. package/src/synthid-http-runtime/runtime-navigator-compat.mjs +99 -0
  82. package/src/synthid-http-runtime/runtime-permissions-binding.mjs +64 -0
  83. package/src/synthid-http-runtime/runtime-permissions-control.mjs +143 -0
  84. package/src/synthid-http-runtime/runtime-web-compat.mjs +639 -0
  85. package/src/synthid-http-runtime/runtime-webidl-callable-control.mjs +151 -0
  86. package/src/synthid-http-runtime/runtime-webidl-realm-compat.mjs +132 -0
  87. package/src/synthid-http-runtime/runtime-window-state-compat.mjs +128 -0
  88. package/src/synthid-http-runtime/scripting-parser.mjs +13 -0
  89. package/src/synthid-http-runtime/web-session.mjs +64 -0
  90. package/src/synthid-http-runtime/webidl-brand-errors-preload.mjs +49 -0
  91. package/src/synthid-http-runtime/webidl-callable-source-catalog.mjs +4491 -0
  92. package/src/synthid-http-runtime/webidl-realm-catalog.mjs +124 -0
  93. package/src/synthid-http.ts +290 -0
  94. package/src/synthid-manual.ts +388 -0
  95. package/src/synthid-page.ts +103 -0
  96. package/src/synthid-result.ts +177 -0
  97. package/src/synthid.ts +514 -0
  98. package/src/vision.ts +57 -0
  99. package/webui/index.js +279 -0
@@ -0,0 +1,124 @@
1
+ // Static DOM interface-object catalog; no runtime file or page reads.
2
+ // Source: @typescript/typescript-win32-x64/lib/lib.dom.d.ts
3
+ // SHA256 (UTF-8 source): d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f
4
+ // Extracted top-level declare-var blocks with a prototype member; added standard Image/Audio/Option aliases.
5
+ // ECMAScript intrinsics, typed arrays, ArrayBuffer/DataView, Proxy, eval and WebAssembly are excluded.
6
+ // Catalog membership proves only a standard name; callers must separately prove per-window ownership.
7
+ export const webIdlConstructorNames=Object.freeze([
8
+ "AbortController", "AbortSignal", "AbstractRange", "AnalyserNode", "Animation", "AnimationEffect",
9
+ "AnimationEvent", "AnimationPlaybackEvent", "AnimationTimeline", "Attr", "Audio", "AudioBuffer",
10
+ "AudioBufferSourceNode", "AudioContext", "AudioData", "AudioDecoder", "AudioDestinationNode", "AudioEncoder",
11
+ "AudioListener", "AudioNode", "AudioParam", "AudioParamMap", "AudioProcessingEvent", "AudioScheduledSourceNode",
12
+ "AudioWorklet", "AudioWorkletNode", "AuthenticatorAssertionResponse", "AuthenticatorAttestationResponse", "AuthenticatorResponse", "BarProp",
13
+ "BaseAudioContext", "BeforeUnloadEvent", "BiquadFilterNode", "Blob", "BlobEvent", "BroadcastChannel",
14
+ "ByteLengthQueuingStrategy", "CDATASection", "CSSAnimation", "CSSConditionRule", "CSSContainerRule", "CSSCounterStyleRule",
15
+ "CSSFontFaceRule", "CSSFontFeatureValuesRule", "CSSFontPaletteValuesRule", "CSSGroupingRule", "CSSImageValue", "CSSImportRule",
16
+ "CSSKeyframeRule", "CSSKeyframesRule", "CSSKeywordValue", "CSSLayerBlockRule", "CSSLayerStatementRule", "CSSMathClamp",
17
+ "CSSMathInvert", "CSSMathMax", "CSSMathMin", "CSSMathNegate", "CSSMathProduct", "CSSMathSum",
18
+ "CSSMathValue", "CSSMatrixComponent", "CSSMediaRule", "CSSNamespaceRule", "CSSNestedDeclarations", "CSSNumericArray",
19
+ "CSSNumericValue", "CSSPageDescriptors", "CSSPageRule", "CSSPerspective", "CSSPositionTryDescriptors", "CSSPositionTryRule",
20
+ "CSSPropertyRule", "CSSRotate", "CSSRule", "CSSRuleList", "CSSScale", "CSSScopeRule",
21
+ "CSSSkew", "CSSSkewX", "CSSSkewY", "CSSStartingStyleRule", "CSSStyleDeclaration", "CSSStyleProperties",
22
+ "CSSStyleRule", "CSSStyleSheet", "CSSStyleValue", "CSSSupportsRule", "CSSTransformComponent", "CSSTransformValue",
23
+ "CSSTransition", "CSSTranslate", "CSSUnitValue", "CSSUnparsedValue", "CSSVariableReferenceValue", "CSSViewTransitionRule",
24
+ "Cache", "CacheStorage", "CanvasCaptureMediaStreamTrack", "CanvasGradient", "CanvasPattern", "CanvasRenderingContext2D",
25
+ "CaretPosition", "ChannelMergerNode", "ChannelSplitterNode", "CharacterData", "Clipboard", "ClipboardEvent",
26
+ "ClipboardItem", "CloseEvent", "CommandEvent", "Comment", "CompositionEvent", "CompressionStream",
27
+ "ConstantSourceNode", "ContentVisibilityAutoStateChangeEvent", "ConvolverNode", "CookieChangeEvent", "CookieStore", "CookieStoreManager",
28
+ "CountQueuingStrategy", "Credential", "CredentialsContainer", "Crypto", "CryptoKey", "CustomElementRegistry",
29
+ "CustomEvent", "CustomStateSet", "DOMException", "DOMImplementation", "DOMMatrix", "DOMMatrixReadOnly",
30
+ "DOMParser", "DOMPoint", "DOMPointReadOnly", "DOMQuad", "DOMRect", "DOMRectList",
31
+ "DOMRectReadOnly", "DOMStringList", "DOMStringMap", "DOMTokenList", "DataTransfer", "DataTransferItem",
32
+ "DataTransferItemList", "DecompressionStream", "DelayNode", "DeviceMotionEvent", "DeviceOrientationEvent", "DigitalCredential",
33
+ "Document", "DocumentFragment", "DocumentTimeline", "DocumentType", "DragEvent", "DynamicsCompressorNode",
34
+ "Element", "ElementInternals", "EncodedAudioChunk", "EncodedVideoChunk", "ErrorEvent", "Event",
35
+ "EventCounts", "EventSource", "EventTarget", "External", "File", "FileList",
36
+ "FileReader", "FileSystem", "FileSystemDirectoryEntry", "FileSystemDirectoryHandle", "FileSystemDirectoryReader", "FileSystemEntry",
37
+ "FileSystemFileEntry", "FileSystemFileHandle", "FileSystemHandle", "FileSystemWritableFileStream", "FocusEvent", "FontFace",
38
+ "FontFaceSet", "FontFaceSetLoadEvent", "FormData", "FormDataEvent", "FragmentDirective", "GPU",
39
+ "GPUAdapter", "GPUAdapterInfo", "GPUBindGroup", "GPUBindGroupLayout", "GPUBuffer", "GPUCanvasContext",
40
+ "GPUCommandBuffer", "GPUCommandEncoder", "GPUCompilationInfo", "GPUCompilationMessage", "GPUComputePassEncoder", "GPUComputePipeline",
41
+ "GPUDevice", "GPUDeviceLostInfo", "GPUError", "GPUExternalTexture", "GPUInternalError", "GPUOutOfMemoryError",
42
+ "GPUPipelineError", "GPUPipelineLayout", "GPUQuerySet", "GPUQueue", "GPURenderBundle", "GPURenderBundleEncoder",
43
+ "GPURenderPassEncoder", "GPURenderPipeline", "GPUSampler", "GPUShaderModule", "GPUSupportedFeatures", "GPUSupportedLimits",
44
+ "GPUTexture", "GPUTextureView", "GPUUncapturedErrorEvent", "GPUValidationError", "GainNode", "Gamepad",
45
+ "GamepadButton", "GamepadEvent", "GamepadHapticActuator", "Geolocation", "GeolocationCoordinates", "GeolocationPosition",
46
+ "GeolocationPositionError", "HTMLAllCollection", "HTMLAnchorElement", "HTMLAreaElement", "HTMLAudioElement", "HTMLBRElement",
47
+ "HTMLBaseElement", "HTMLBodyElement", "HTMLButtonElement", "HTMLCanvasElement", "HTMLCollection", "HTMLDListElement",
48
+ "HTMLDataElement", "HTMLDataListElement", "HTMLDetailsElement", "HTMLDialogElement", "HTMLDirectoryElement", "HTMLDivElement",
49
+ "HTMLDocument", "HTMLElement", "HTMLEmbedElement", "HTMLFieldSetElement", "HTMLFontElement", "HTMLFormControlsCollection",
50
+ "HTMLFormElement", "HTMLFrameElement", "HTMLFrameSetElement", "HTMLHRElement", "HTMLHeadElement", "HTMLHeadingElement",
51
+ "HTMLHtmlElement", "HTMLIFrameElement", "HTMLImageElement", "HTMLInputElement", "HTMLLIElement", "HTMLLabelElement",
52
+ "HTMLLegendElement", "HTMLLinkElement", "HTMLMapElement", "HTMLMarqueeElement", "HTMLMediaElement", "HTMLMenuElement",
53
+ "HTMLMetaElement", "HTMLMeterElement", "HTMLModElement", "HTMLOListElement", "HTMLObjectElement", "HTMLOptGroupElement",
54
+ "HTMLOptionElement", "HTMLOptionsCollection", "HTMLOutputElement", "HTMLParagraphElement", "HTMLParamElement", "HTMLPictureElement",
55
+ "HTMLPreElement", "HTMLProgressElement", "HTMLQuoteElement", "HTMLScriptElement", "HTMLSelectElement", "HTMLSlotElement",
56
+ "HTMLSourceElement", "HTMLSpanElement", "HTMLStyleElement", "HTMLTableCaptionElement", "HTMLTableCellElement", "HTMLTableColElement",
57
+ "HTMLTableElement", "HTMLTableRowElement", "HTMLTableSectionElement", "HTMLTemplateElement", "HTMLTextAreaElement", "HTMLTimeElement",
58
+ "HTMLTitleElement", "HTMLTrackElement", "HTMLUListElement", "HTMLUnknownElement", "HTMLVideoElement", "HashChangeEvent",
59
+ "Headers", "Highlight", "HighlightRegistry", "History", "IDBCursor", "IDBCursorWithValue",
60
+ "IDBDatabase", "IDBFactory", "IDBIndex", "IDBKeyRange", "IDBObjectStore", "IDBOpenDBRequest",
61
+ "IDBRequest", "IDBTransaction", "IDBVersionChangeEvent", "IIRFilterNode", "IdleDeadline", "Image",
62
+ "ImageBitmap", "ImageBitmapRenderingContext", "ImageCapture", "ImageData", "ImageDecoder", "ImageTrack",
63
+ "ImageTrackList", "InputDeviceInfo", "InputEvent", "IntersectionObserver", "IntersectionObserverEntry", "KeyboardEvent",
64
+ "KeyframeEffect", "LargestContentfulPaint", "Location", "Lock", "LockManager", "MIDIAccess",
65
+ "MIDIConnectionEvent", "MIDIInput", "MIDIInputMap", "MIDIMessageEvent", "MIDIOutput", "MIDIOutputMap",
66
+ "MIDIPort", "MathMLElement", "MediaCapabilities", "MediaDeviceInfo", "MediaDevices", "MediaElementAudioSourceNode",
67
+ "MediaEncryptedEvent", "MediaError", "MediaKeyMessageEvent", "MediaKeySession", "MediaKeyStatusMap", "MediaKeySystemAccess",
68
+ "MediaKeys", "MediaList", "MediaMetadata", "MediaQueryList", "MediaQueryListEvent", "MediaRecorder",
69
+ "MediaSession", "MediaSource", "MediaSourceHandle", "MediaStream", "MediaStreamAudioDestinationNode", "MediaStreamAudioSourceNode",
70
+ "MediaStreamTrack", "MediaStreamTrackEvent", "MessageChannel", "MessageEvent", "MessagePort", "MimeType",
71
+ "MimeTypeArray", "MouseEvent", "MutationObserver", "MutationRecord", "NamedNodeMap", "NavigateEvent",
72
+ "Navigation", "NavigationActivation", "NavigationCurrentEntryChangeEvent", "NavigationDestination", "NavigationHistoryEntry", "NavigationPrecommitController",
73
+ "NavigationPreloadManager", "NavigationTransition", "Navigator", "NavigatorLogin", "Node", "NodeIterator",
74
+ "NodeList", "Notification", "OfflineAudioCompletionEvent", "OfflineAudioContext", "OffscreenCanvas", "OffscreenCanvasRenderingContext2D",
75
+ "Option", "OscillatorNode", "OverconstrainedError", "PageRevealEvent", "PageSwapEvent", "PageTransitionEvent",
76
+ "PannerNode", "Path2D", "PaymentAddress", "PaymentMethodChangeEvent", "PaymentRequest", "PaymentRequestUpdateEvent",
77
+ "PaymentResponse", "Performance", "PerformanceEntry", "PerformanceEventTiming", "PerformanceMark", "PerformanceMeasure",
78
+ "PerformanceNavigation", "PerformanceNavigationTiming", "PerformanceObserver", "PerformanceObserverEntryList", "PerformancePaintTiming", "PerformanceResourceTiming",
79
+ "PerformanceServerTiming", "PerformanceTiming", "PeriodicWave", "PermissionStatus", "Permissions", "PictureInPictureEvent",
80
+ "PictureInPictureWindow", "Plugin", "PluginArray", "PointerEvent", "PopStateEvent", "ProcessingInstruction",
81
+ "ProgressEvent", "PromiseRejectionEvent", "PublicKeyCredential", "PushManager", "PushSubscription", "PushSubscriptionOptions",
82
+ "RTCCertificate", "RTCDTMFSender", "RTCDTMFToneChangeEvent", "RTCDataChannel", "RTCDataChannelEvent", "RTCDtlsTransport",
83
+ "RTCEncodedAudioFrame", "RTCEncodedVideoFrame", "RTCError", "RTCErrorEvent", "RTCIceCandidate", "RTCIceTransport",
84
+ "RTCPeerConnection", "RTCPeerConnectionIceErrorEvent", "RTCPeerConnectionIceEvent", "RTCRtpReceiver", "RTCRtpScriptTransform", "RTCRtpSender",
85
+ "RTCRtpTransceiver", "RTCSctpTransport", "RTCSessionDescription", "RTCStatsReport", "RTCTrackEvent", "RadioNodeList",
86
+ "Range", "ReadableByteStreamController", "ReadableStream", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableStreamDefaultController",
87
+ "ReadableStreamDefaultReader", "RemotePlayback", "ReportingObserver", "Request", "ResizeObserver", "ResizeObserverEntry",
88
+ "ResizeObserverSize", "Response", "SVGAElement", "SVGAngle", "SVGAnimateElement", "SVGAnimateMotionElement",
89
+ "SVGAnimateTransformElement", "SVGAnimatedAngle", "SVGAnimatedBoolean", "SVGAnimatedEnumeration", "SVGAnimatedInteger", "SVGAnimatedLength",
90
+ "SVGAnimatedLengthList", "SVGAnimatedNumber", "SVGAnimatedNumberList", "SVGAnimatedPreserveAspectRatio", "SVGAnimatedRect", "SVGAnimatedString",
91
+ "SVGAnimatedTransformList", "SVGAnimationElement", "SVGCircleElement", "SVGClipPathElement", "SVGComponentTransferFunctionElement", "SVGDefsElement",
92
+ "SVGDescElement", "SVGElement", "SVGEllipseElement", "SVGFEBlendElement", "SVGFEColorMatrixElement", "SVGFEComponentTransferElement",
93
+ "SVGFECompositeElement", "SVGFEConvolveMatrixElement", "SVGFEDiffuseLightingElement", "SVGFEDisplacementMapElement", "SVGFEDistantLightElement", "SVGFEDropShadowElement",
94
+ "SVGFEFloodElement", "SVGFEFuncAElement", "SVGFEFuncBElement", "SVGFEFuncGElement", "SVGFEFuncRElement", "SVGFEGaussianBlurElement",
95
+ "SVGFEImageElement", "SVGFEMergeElement", "SVGFEMergeNodeElement", "SVGFEMorphologyElement", "SVGFEOffsetElement", "SVGFEPointLightElement",
96
+ "SVGFESpecularLightingElement", "SVGFESpotLightElement", "SVGFETileElement", "SVGFETurbulenceElement", "SVGFilterElement", "SVGForeignObjectElement",
97
+ "SVGGElement", "SVGGeometryElement", "SVGGradientElement", "SVGGraphicsElement", "SVGImageElement", "SVGLength",
98
+ "SVGLengthList", "SVGLineElement", "SVGLinearGradientElement", "SVGMPathElement", "SVGMarkerElement", "SVGMaskElement",
99
+ "SVGMetadataElement", "SVGNumber", "SVGNumberList", "SVGPathElement", "SVGPatternElement", "SVGPointList",
100
+ "SVGPolygonElement", "SVGPolylineElement", "SVGPreserveAspectRatio", "SVGRadialGradientElement", "SVGRectElement", "SVGSVGElement",
101
+ "SVGScriptElement", "SVGSetElement", "SVGStopElement", "SVGStringList", "SVGStyleElement", "SVGSwitchElement",
102
+ "SVGSymbolElement", "SVGTSpanElement", "SVGTextContentElement", "SVGTextElement", "SVGTextPathElement", "SVGTextPositioningElement",
103
+ "SVGTitleElement", "SVGTransform", "SVGTransformList", "SVGUnitTypes", "SVGUseElement", "SVGViewElement",
104
+ "Sanitizer", "Scheduler", "Screen", "ScreenOrientation", "ScriptProcessorNode", "ScrollTimeline",
105
+ "SecurityPolicyViolationEvent", "Selection", "ServiceWorker", "ServiceWorkerContainer", "ServiceWorkerRegistration", "ShadowRoot",
106
+ "SharedWorker", "SourceBuffer", "SourceBufferList", "SpeechRecognitionAlternative", "SpeechRecognitionErrorEvent", "SpeechRecognitionEvent",
107
+ "SpeechRecognitionResult", "SpeechRecognitionResultList", "SpeechSynthesis", "SpeechSynthesisErrorEvent", "SpeechSynthesisEvent", "SpeechSynthesisUtterance",
108
+ "SpeechSynthesisVoice", "StaticRange", "StereoPannerNode", "Storage", "StorageEvent", "StorageManager",
109
+ "StylePropertyMap", "StylePropertyMapReadOnly", "StyleSheet", "StyleSheetList", "SubmitEvent", "SubtleCrypto",
110
+ "TaskController", "TaskPriorityChangeEvent", "TaskSignal", "Text", "TextDecoder", "TextDecoderStream",
111
+ "TextEncoder", "TextEncoderStream", "TextEvent", "TextMetrics", "TextTrack", "TextTrackCue",
112
+ "TextTrackCueList", "TextTrackList", "TimeRanges", "ToggleEvent", "Touch", "TouchEvent",
113
+ "TouchList", "TrackEvent", "TransformStream", "TransformStreamDefaultController", "TransitionEvent", "TreeWalker",
114
+ "UIEvent", "URL", "URLPattern", "URLSearchParams", "UserActivation", "VTTCue",
115
+ "VTTRegion", "ValidityState", "VideoColorSpace", "VideoDecoder", "VideoEncoder", "VideoFrame",
116
+ "VideoPlaybackQuality", "ViewTimeline", "ViewTransition", "ViewTransitionTypeSet", "VisualViewport", "WGSLLanguageFeatures",
117
+ "WakeLock", "WakeLockSentinel", "WaveShaperNode", "WebGL2RenderingContext", "WebGLActiveInfo", "WebGLBuffer",
118
+ "WebGLContextEvent", "WebGLFramebuffer", "WebGLProgram", "WebGLQuery", "WebGLRenderbuffer", "WebGLRenderingContext",
119
+ "WebGLSampler", "WebGLShader", "WebGLShaderPrecisionFormat", "WebGLSync", "WebGLTexture", "WebGLTransformFeedback",
120
+ "WebGLUniformLocation", "WebGLVertexArrayObject", "WebSocket", "WebTransport", "WebTransportBidirectionalStream", "WebTransportDatagramDuplexStream",
121
+ "WebTransportError", "WheelEvent", "Window", "Worker", "Worklet", "WritableStream",
122
+ "WritableStreamDefaultController", "WritableStreamDefaultWriter", "XMLDocument", "XMLHttpRequest", "XMLHttpRequestEventTarget", "XMLHttpRequestUpload",
123
+ "XMLSerializer", "XPathEvaluator", "XPathExpression", "XPathResult", "XSLTProcessor",
124
+ ]);
@@ -0,0 +1,290 @@
1
+ import { randomUUID } from 'node:crypto'
2
+ import type { Context } from '@luckylillia-dev/plugin-sdk'
3
+ import type { Image } from './image.js'
4
+ import { SynthIdTokenStore, type SynthIdTokens } from './synthid-auth.js'
5
+ import { parseSynthIdResponse, SynthIdError, type SynthIdResult } from './synthid-result.js'
6
+ import type { LifecycleClient, RequestReference } from './synthid-http-runtime/entry.mjs'
7
+
8
+ const ORIGIN = 'https://synthid.com'
9
+ const TOKEN = 'https://securetoken.googleapis.com/v1/token?key=AIzaSyCjADz3UffE3DF5HZ--7MgVEXrbt6Bgcck'
10
+ const CREATE = 'https://waa-pa.clients6.google.com/$rpc/google.internal.waa.v1.Waa/Create'
11
+ const UPLOAD = 'https://content-push.googleapis.com/upload/'
12
+ const DROPZONE = '/synthid-demo-drop-zone/ttl_1d/'
13
+ const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36'
14
+ const EXTENSIONS: Record<string, string> = {
15
+ 'image/jpeg': 'jpg', 'image/png': 'png', 'image/webp': 'webp', 'image/gif': 'gif',
16
+ 'image/bmp': 'bmp', 'image/avif': 'avif', 'image/heic': 'heic', 'image/heif': 'heif', 'image/tiff': 'tiff',
17
+ }
18
+ export interface HttpSynthIdOptions {
19
+ refreshToken: string
20
+ timeout: number
21
+ /** Replace the interpreter process in isolated wire tests. */
22
+ loadRuntime?: () => Promise<typeof import('./synthid-http-runtime/entry.mjs')>
23
+ }
24
+ interface Operation { signal: AbortSignal; reference: RequestReference }
25
+ interface Job {
26
+ run?: () => Promise<SynthIdResult>
27
+ resolve: (result: SynthIdResult) => void
28
+ reject: (error: unknown) => void
29
+ detach: () => void
30
+ }
31
+ interface Account { queue: Job[]; running: boolean; retryAt: number }
32
+ const accounts = new Map<string, Account>()
33
+ const cancelled = () => new SynthIdError('cancelled', 'SynthID detection was cancelled')
34
+ function prune(key: string, account: Account): void {
35
+ if (!account.running && !account.queue.length && account.retryAt <= Date.now() && accounts.get(key) === account) accounts.delete(key)
36
+ }
37
+ function drain(key: string, account: Account): void {
38
+ if (account.running) return
39
+ const job = account.queue.shift()
40
+ if (!job) return prune(key, account)
41
+ const run = job.run!
42
+ job.run = undefined
43
+ job.detach()
44
+ account.running = true
45
+ void Promise.resolve().then(run).then(result => {
46
+ if (result.status === 'quota_exceeded') account.retryAt = Date.now() + (result.retryAfterSeconds || 60) * 1000
47
+ job.resolve(result)
48
+ }, error => {
49
+ if (error instanceof SynthIdError && error.kind === 'rate-limit') account.retryAt = Date.now() + (error.retryAfterSeconds || 60) * 1000
50
+ job.reject(error)
51
+ }).finally(() => { account.running = false; drain(key, account) })
52
+ }
53
+ function retryAfter(value: string | null): number {
54
+ const seconds = value && /^\d+(?:\.\d+)?$/.test(value) ? Number(value) : value ? (Date.parse(value) - Date.now()) / 1000 : 60
55
+ return Number.isFinite(seconds) && seconds > 0 ? Math.ceil(seconds) : 60
56
+ }
57
+ function failure(error: unknown, signal: AbortSignal): SynthIdError {
58
+ if (error instanceof SynthIdError) return error
59
+ if (signal.aborted) return signal.reason?.name === 'TimeoutError' ? new SynthIdError('timeout', 'SynthID detection timed out') : cancelled()
60
+ const code = (error as { code?: unknown })?.code
61
+ return new SynthIdError(['WORKER_TIMEOUT', 'OPERATION_TIMEOUT', 'LIFETIME_TIMEOUT'].includes(String(code)) ? 'timeout' : 'response', 'SynthID interpreter could not complete detection')
62
+ }
63
+
64
+ /** All remote I/O uses the host HTTP service. Every image gets a fresh
65
+ * interpreter process, upload path and verification token bound to that path. */
66
+ export class HttpSynthIdClient {
67
+ private readonly abort = new AbortController()
68
+ private readonly active = new Set<Promise<SynthIdResult>>()
69
+ private readonly tokens: SynthIdTokenStore
70
+ private runtime?: Promise<typeof import('./synthid-http-runtime/entry.mjs')>
71
+
72
+ constructor(private readonly ctx: Context, private readonly options: HttpSynthIdOptions) {
73
+ if (typeof options.refreshToken !== 'string' || !/^[\x21-\x7e]+$/.test(options.refreshToken.trim())
74
+ || !Number.isInteger(options.timeout) || options.timeout < 1 || options.timeout > 120_000) {
75
+ throw new SynthIdError('config', 'SynthID login credential or timeout is invalid')
76
+ }
77
+ this.options = { ...options }
78
+ this.tokens = new SynthIdTokenStore(ctx, options.refreshToken.trim())
79
+ ctx.effect(() => () => this.dispose())
80
+ }
81
+
82
+ async dispose(): Promise<void> {
83
+ this.abort.abort()
84
+ await Promise.allSettled([...this.active])
85
+ }
86
+
87
+ detect(image: Image, external?: AbortSignal): Promise<SynthIdResult> {
88
+ const signal = external ? AbortSignal.any([this.abort.signal, external]) : this.abort.signal
89
+ const mime = image.type.split(';')[0].trim().toLowerCase()
90
+ if (signal.aborted) return Promise.reject(cancelled())
91
+ if (!Object.hasOwn(EXTENSIONS, mime) || !image.data.byteLength || image.data.byteLength > 20 * 1024 * 1024) {
92
+ return Promise.reject(new SynthIdError('request', 'SynthID needs a supported, non-empty image of at most 20 MB'))
93
+ }
94
+ if (this.active.size >= 4) return Promise.reject(new SynthIdError('busy', 'SynthID account queue is full'))
95
+ const task = this.prepare(image, mime, signal).catch(error => { throw failure(error, signal) })
96
+ this.active.add(task)
97
+ void task.then(() => this.active.delete(task), () => this.active.delete(task))
98
+ return task
99
+ }
100
+
101
+ private async prepare(image: Image, mime: string, signal: AbortSignal): Promise<SynthIdResult> {
102
+ if (!this.options.loadRuntime && Number(process.versions.node.split('.')[0]) < 24) {
103
+ throw new SynthIdError('runtime', 'SynthID HTTP runtime requires Node.js 24 or later')
104
+ }
105
+ this.runtime ??= (this.options.loadRuntime ?? (() => import('./synthid-http-runtime/entry.mjs')))()
106
+ const entry = await this.runtime
107
+ const reference = entry.createIndependentRequestReference({ userAgent: USER_AGENT })
108
+ const started = Date.now()
109
+ const tokens = await this.authenticate({ signal: AbortSignal.any([signal, AbortSignal.timeout(this.options.timeout)]), reference })
110
+ signal.throwIfAborted()
111
+ const authElapsed = Date.now() - started
112
+ for (const [key, account] of accounts) prune(key, account)
113
+ const key = tokens.userId
114
+ const account = accounts.get(key) ?? { queue: [], running: false, retryAt: 0 }
115
+ accounts.set(key, account)
116
+ if (account.queue.length + Number(account.running) >= 4) throw new SynthIdError('busy', 'SynthID account queue is full')
117
+ return new Promise<SynthIdResult>((resolve, reject) => {
118
+ const job: Job = {
119
+ run: async () => {
120
+ signal.throwIfAborted()
121
+ if (account.retryAt > Date.now()) throw new SynthIdError('rate-limit', 'SynthID account is cooling down', undefined, Math.ceil((account.retryAt - Date.now()) / 1000))
122
+ const deadline = AbortSignal.timeout(Math.max(1, this.options.timeout - authElapsed))
123
+ const operation = { reference, signal: AbortSignal.any([signal, deadline]) }
124
+ try {
125
+ for (let attempt = 0, auth = tokens; ; attempt++) {
126
+ try { return await this.detectQueued(image, mime, auth, operation, entry) }
127
+ catch (error) {
128
+ if (!(error instanceof SynthIdError) || error.code !== 16 || attempt) throw error
129
+ auth = await this.authenticate(operation, true)
130
+ }
131
+ }
132
+ } catch (error) { throw failure(error, operation.signal) }
133
+ }, resolve, reject, detach: () => signal.removeEventListener('abort', cancel),
134
+ }
135
+ const cancel = () => {
136
+ const index = account.queue.indexOf(job)
137
+ if (index < 0) return
138
+ account.queue.splice(index, 1)
139
+ job.run = undefined
140
+ job.detach()
141
+ reject(cancelled())
142
+ prune(key, account)
143
+ }
144
+ signal.addEventListener('abort', cancel, { once: true })
145
+ account.queue.push(job)
146
+ drain(key, account)
147
+ })
148
+ }
149
+
150
+ private async request(operation: Operation, url: string, init: RequestInit, stage: string): Promise<Response> {
151
+ const { signal, reference } = operation
152
+ signal.throwIfAborted()
153
+ const headers = new Headers(init.headers)
154
+ for (const [key, value] of Object.entries(reference.stages[stage]?.headers ?? {})) if (!headers.has(key)) headers.set(key, value)
155
+ headers.set('user-agent', USER_AGENT)
156
+ headers.set('referer', ORIGIN + '/')
157
+ headers.set('accept-language', 'en-US,en;q=0.9')
158
+ headers.delete('content-length')
159
+ let response: Response
160
+ try { response = await this.ctx.http.fetch(url, { ...init, headers, signal, redirect: 'error' }) }
161
+ catch {
162
+ if (signal.aborted) throw failure(undefined, signal)
163
+ throw new SynthIdError('network', `SynthID ${stage} could not connect`)
164
+ }
165
+ if (!response.ok) {
166
+ await response.body?.cancel()
167
+ const status = response.status
168
+ const kind = status === 429 ? 'rate-limit' : status === 401 || stage === 'auth' && status === 400 ? 'auth'
169
+ : status === 403 ? 'permission' : status >= 500 ? 'server' : 'request'
170
+ throw new SynthIdError(kind, `SynthID ${stage} returned HTTP ${status}`, stage === 'detect' && status === 401 ? 16 : status,
171
+ status === 429 ? retryAfter(response.headers.get('retry-after')) : undefined)
172
+ }
173
+ const limit = stage === 'page' || stage === 'challenge' ? 4 * 1024 * 1024 : 1024 * 1024
174
+ const reader = response.body?.getReader()
175
+ const chunks: Uint8Array[] = []
176
+ let size = 0
177
+ const abort = () => { void reader?.cancel().catch(() => {}) }
178
+ signal.addEventListener('abort', abort, { once: true })
179
+ try {
180
+ if (reader) for (;;) {
181
+ signal.throwIfAborted()
182
+ const { done, value } = await reader.read()
183
+ signal.throwIfAborted()
184
+ if (done) break
185
+ if ((size += value.byteLength) > limit) throw new SynthIdError('response', `SynthID ${stage} returned an oversized response`)
186
+ chunks.push(value)
187
+ }
188
+ return new Response(Buffer.concat(chunks, size), { status: response.status, headers: response.headers })
189
+ } catch (error) { throw failure(error, signal) }
190
+ finally {
191
+ signal.removeEventListener('abort', abort)
192
+ if (reader) { await reader.cancel().catch(() => {}); reader.releaseLock() }
193
+ }
194
+ }
195
+
196
+ private authenticate(operation: Operation, force = false): Promise<SynthIdTokens> {
197
+ return this.tokens.get(async refreshToken => {
198
+ const response = await this.request(operation, TOKEN, {
199
+ method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
200
+ body: new URLSearchParams({ grant_type: 'refresh_token', refresh_token: refreshToken }),
201
+ }, 'auth')
202
+ try { return await response.json() as Record<string, unknown> }
203
+ catch { throw new SynthIdError('response', 'SynthID token refresh returned an invalid response') }
204
+ }, force, operation.signal).catch(error => { throw failure(error, operation.signal) })
205
+ }
206
+
207
+ private async detectQueued(image: Image, mime: string, auth: SynthIdTokens, operation: Operation,
208
+ entry: typeof import('./synthid-http-runtime/entry.mjs')): Promise<SynthIdResult> {
209
+ let lifecycle: LifecycleClient | undefined
210
+ const request = (url: string, init: RequestInit = {}, stage: string) => this.request(operation, url, init, stage)
211
+ try {
212
+ const session = await entry.createLifecycleWebSession({ fetch: (url, init = {}) => request(url, init,
213
+ new URL(url).pathname.endsWith('/batchexecute') ? 'detect' : new URL(url).pathname.endsWith('/bscframe') ? 'frame' : 'page') },
214
+ USER_AGENT, { networkMeasurements: true, collapseConnectionTiming: true })
215
+ if (session.config.eptZe !== '/_/WatermarkApp/') throw new SynthIdError('response', 'SynthID page route is not supported')
216
+ const challenge = entry.parseOfficialChallenge(await (await request(CREATE, {
217
+ method: 'POST', body: JSON.stringify(['UzdguikIn08nBCK5a0xw']),
218
+ headers: { Origin: ORIGIN, 'Content-Type': 'application/json+protobuf', 'X-Goog-Api-Key': 'AIzaSyBGb5fGAyC-pRcRU6MUHb__b_vKha71HRE', 'X-User-Agent': 'grpc-web-javascript/0.1' },
219
+ }, 'challenge')).json())
220
+ let interpreter = challenge.interpreterJavascript?.privateDoNotAccessOrElseSafeScriptWrappedValue
221
+ let interpreterSourceUrl: string | undefined
222
+ if (!interpreter) {
223
+ const raw = challenge.interpreterUrl?.privateDoNotAccessOrElseTrustedResourceUrlWrappedValue
224
+ const url = new URL(String(raw), ORIGIN)
225
+ if (!raw || url.protocol !== 'https:' || !['www.google.com', 'www.gstatic.com'].includes(url.hostname)
226
+ || url.port || url.username || url.password || !url.pathname.startsWith('/js/')) throw new SynthIdError('response', 'SynthID interpreter location is not supported')
227
+ interpreterSourceUrl = url.href
228
+ interpreter = await (await request(url.href, {}, 'interpreter')).text()
229
+ }
230
+ let frameUrl: string | undefined, frameHTML: string | undefined
231
+ const suffix = challenge.program.lastIndexOf('//')
232
+ if (suffix >= 0) {
233
+ const url = new URL(Buffer.from(challenge.program.slice(suffix + 2), 'base64').toString('utf8'), ORIGIN)
234
+ if (url.protocol !== 'https:' || !['synthid.com', 'www.google.com', 'www.gstatic.com'].includes(url.hostname)
235
+ || url.port || url.username || url.password) throw new SynthIdError('response', 'SynthID frame location is not supported')
236
+ frameUrl = url.href
237
+ frameHTML = await (url.origin === ORIGIN ? await session.request(frameUrl) : await request(frameUrl, {}, 'frame')).text()
238
+ }
239
+ lifecycle = entry.createLifecycleClient({ signal: operation.signal,
240
+ webidlBrandErrors: true,
241
+ timeouts: { init: Math.min(this.options.timeout, 25_000), snapshot: Math.min(this.options.timeout, 15_000) }, maxLifetimeMs: Math.max(100, this.options.timeout) })
242
+ const initialized = await lifecycle.initialize({ ...await session.environment(),
243
+ program: challenge.program, globalName: challenge.globalName, rawExperiments: challenge.clientExperimentsStateBlob ?? '',
244
+ experiments: entry.normalizeOfficialExperimentState(challenge.clientExperimentsStateBlob),
245
+ interpreter, interpreterSourceUrl, frameUrl, frameHTML, userAgent: USER_AGENT,
246
+ eventClockCompatibility: true, enablePointerDiagnostics: true, clockPrecision100us: true,
247
+ runtimeWebCompatibility: true, runtimeChildWebCompatibility: true, runtimeNavigatorCompatibility: true,
248
+ runtimeWindowStateCompatibility: true, runtimeNetworkCompatibility: true, runtimeDetachedFrameCompatibility: true,
249
+ runtimeWebIdlRealmCompatibility: true, runtimeWebIdlCallableControl: true, runtimePermissionsBinding: true,
250
+ runtimeAnchorHrefTranslate: true, runtimeMouseMediaCompatibility: true, runtimeChromeCsi: true, runtimeCssProperties: true,
251
+ javascriptBindings: true, activationStateControl: true, activationTimingControl: true,
252
+ virtualFocusControl: true, webidlBrandErrors: true,
253
+ })
254
+ if (!initialized.success || !(await lifecycle.dispatchPointerDiagnostics()).success) throw new SynthIdError('response', 'SynthID interpreter initialization failed')
255
+ const path = 'users/' + auth.userId + '/files/' + randomUUID()
256
+ const blobref = DROPZONE + path
257
+ const generated = await lifecycle.snapshot(blobref)
258
+ if (!generated.success || typeof generated.bgToken !== 'string' || !/^![\x21-\x7e]+$/.test(generated.bgToken)) throw new SynthIdError('response', 'SynthID verification token generation failed')
259
+ const headers = { Authorization: 'Basic amI5dChNbS0qNjFlczJJVzpyZyRHNUp1QENpV29OJVNS', 'Push-ID': 'feeds/szvztmw263lqqp',
260
+ 'Push-Filename': path, 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
261
+ const start = await request(UPLOAD, { method: 'POST', body: `file_name image.${EXTENSIONS[mime]}`,
262
+ headers: { ...headers, 'X-Goog-Upload-Protocol': 'resumable', 'X-Goog-Upload-Command': 'start', 'X-Goog-Upload-Header-Content-Length': String(image.data.byteLength) } }, 'start')
263
+ let uploadUrl: URL
264
+ try {
265
+ uploadUrl = new URL(start.headers.get('x-goog-upload-url') ?? '')
266
+ if (uploadUrl.origin !== 'https://content-push.googleapis.com' || uploadUrl.username || uploadUrl.password
267
+ || !/^\/upload(?:\/|$)/.test(uploadUrl.pathname)) throw new Error()
268
+ } catch { throw new SynthIdError('response', 'SynthID upload URL is not supported') }
269
+ const uploaded = await request(uploadUrl.href, { method: 'POST', body: image.data,
270
+ headers: { ...headers, 'X-Goog-Upload-Command': 'upload, finalize', 'X-Goog-Upload-Offset': '0' } }, 'upload, finalize')
271
+ if (uploaded.headers.get('x-goog-upload-status') !== 'final' || (await uploaded.text()).trim() !== blobref) throw new SynthIdError('response', 'SynthID upload did not finalize at the generated path')
272
+ const endpoint = new URL('/_/WatermarkApp/data/batchexecute', ORIGIN)
273
+ if (typeof session.config.cfb2h !== 'string' || !session.config.cfb2h || typeof session.config.FdrFJe !== 'string' || !session.config.FdrFJe) throw new SynthIdError('response', 'SynthID page metadata is incomplete')
274
+ endpoint.search = new URLSearchParams({ rpcids: 'TZRKo', 'source-path': '/image-detection', bl: session.config.cfb2h,
275
+ 'f.sid': session.config.FdrFJe, hl: session.config.hl || 'en-US', _reqid: session.nextRequestId(), rt: 'c' }).toString()
276
+ const form = entry.attachWebXsrf(new URLSearchParams({ 'f.req': JSON.stringify([[['TZRKo', JSON.stringify([null, [[[mime, null, null, null, null, null, blobref]]], 0]), null, 'generic']]]) }), session.config)
277
+ const response = await session.request(endpoint.href, { method: 'POST', body: form.toString() + '&', headers: {
278
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', 'X-Same-Domain': '1',
279
+ 'X-Goog-Ext-525006476-Jspb': JSON.stringify([auth.idToken, null, null, null, null, generated.bgToken]),
280
+ } })
281
+ generated.bgToken = ''
282
+ return parseSynthIdResponse(await response.text())
283
+ } finally {
284
+ if (lifecycle) {
285
+ const disposed = await lifecycle.dispose()
286
+ if (!disposed.success || lifecycle.telemetry.exited === false) throw new SynthIdError('runtime', 'SynthID interpreter cleanup failed')
287
+ }
288
+ }
289
+ }
290
+ }