@utk09/ui-observability 0.11.0 → 1.0.0
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.
- package/CHANGELOG.md +481 -0
- package/README.md +73 -669
- package/bin/uiobs.mjs +1 -1
- package/dist/{batch-CL9uWYY3.js → batch-CXmPmTse.js} +3 -3
- package/dist/batch-CXmPmTse.js.map +1 -0
- package/dist/{batch-C8OcWR2L.cjs → batch-mmPigCpi.cjs} +2 -2
- package/dist/batch-mmPigCpi.cjs.map +1 -0
- package/dist/bus/bus.d.cts +331 -0
- package/dist/bus/bus.d.ts +108 -57
- package/dist/bus/links.d.cts +132 -0
- package/dist/bus/links.d.ts +22 -7
- package/dist/bus/validation.d.cts +16 -0
- package/dist/bus/validation.d.ts +11 -2
- package/dist/bus-C39wspFV.js +775 -0
- package/dist/bus-C39wspFV.js.map +1 -0
- package/dist/bus-_EaOVPGq.cjs +2 -0
- package/dist/bus-_EaOVPGq.cjs.map +1 -0
- package/dist/capture/console.d.cts +37 -0
- package/dist/capture/console.d.ts +11 -11
- package/dist/capture/errors.d.cts +32 -0
- package/dist/capture/errors.d.ts +7 -7
- package/dist/capture/interactions.d.cts +48 -0
- package/dist/capture/interactions.d.ts +15 -15
- package/dist/capture/lifecycle.d.cts +20 -0
- package/dist/capture/lifecycle.d.ts +4 -4
- package/dist/capture/long-frames.d.cts +31 -0
- package/dist/capture/long-frames.d.ts +7 -7
- package/dist/capture/network.d.cts +57 -0
- package/dist/capture/network.d.ts +18 -18
- package/dist/capture/profiler-frames.d.cts +44 -0
- package/dist/capture/profiler-frames.d.ts +44 -0
- package/dist/capture/replay-buffer.d.cts +45 -0
- package/dist/capture/replay-buffer.d.ts +45 -0
- package/dist/capture/replay-upload.d.cts +79 -0
- package/dist/capture/replay-upload.d.ts +79 -0
- package/dist/capture/replay.d.cts +114 -0
- package/dist/capture/replay.d.ts +114 -0
- package/dist/capture/reports.d.cts +17 -0
- package/dist/capture/reports.d.ts +3 -3
- package/dist/capture/resource-timing.d.cts +14 -0
- package/dist/capture/resource-timing.d.ts +2 -2
- package/dist/capture/server-timing.d.cts +19 -0
- package/dist/capture/server-timing.d.ts +3 -3
- package/dist/capture/storm.d.cts +13 -0
- package/dist/capture/storm.d.ts +7 -7
- package/dist/capture/types.d.cts +128 -0
- package/dist/capture/types.d.ts +54 -41
- package/dist/capture/unclean-exit.d.cts +31 -0
- package/dist/capture/unclean-exit.d.ts +9 -9
- package/dist/capture/user-timing.d.cts +22 -0
- package/dist/capture/user-timing.d.ts +4 -4
- package/dist/capture/web-socket.d.cts +40 -0
- package/dist/capture/web-socket.d.ts +14 -14
- package/dist/capture/web-vitals.d.cts +40 -0
- package/dist/capture/web-vitals.d.ts +21 -8
- package/dist/compression-CvED_Jel.cjs +2 -0
- package/dist/compression-CvED_Jel.cjs.map +1 -0
- package/dist/compression-tVtXwVjX.js +11 -0
- package/dist/compression-tVtXwVjX.js.map +1 -0
- package/dist/config-DUs7uHHt.cjs +2 -0
- package/dist/config-DUs7uHHt.cjs.map +1 -0
- package/dist/config-SgQcCP1_.js +560 -0
- package/dist/config-SgQcCP1_.js.map +1 -0
- package/dist/console-BGgGnjSi.js +81 -0
- package/dist/console-BGgGnjSi.js.map +1 -0
- package/dist/console-CSZ5_Vx5.cjs +2 -0
- package/dist/console-CSZ5_Vx5.cjs.map +1 -0
- package/dist/constants-CUyd9cTZ.js +357 -0
- package/dist/constants-CUyd9cTZ.js.map +1 -0
- package/dist/constants-CqdJhTxH.cjs +2 -0
- package/dist/constants-CqdJhTxH.cjs.map +1 -0
- package/dist/constants.d.cts +751 -0
- package/dist/constants.d.ts +231 -116
- package/dist/core/breadcrumbs.d.cts +54 -0
- package/dist/core/breadcrumbs.d.ts +21 -15
- package/dist/core/config.d.cts +45 -0
- package/dist/core/config.d.ts +33 -5
- package/dist/core/context.d.cts +24 -0
- package/dist/core/context.d.ts +8 -13
- package/dist/core/debug-buffer.d.cts +34 -0
- package/dist/core/debug-buffer.d.ts +13 -13
- package/dist/core/debug-bundle.d.cts +12 -0
- package/dist/core/debug-bundle.d.ts +6 -6
- package/dist/core/deferred.d.cts +7 -0
- package/dist/core/deferred.d.ts +4 -4
- package/dist/core/diagnostics.d.cts +86 -0
- package/dist/core/diagnostics.d.ts +25 -22
- package/dist/core/drops.d.cts +39 -0
- package/dist/core/drops.d.ts +22 -12
- package/dist/core/hold-buffer.d.cts +36 -0
- package/dist/core/hold-buffer.d.ts +16 -7
- package/dist/core/journey.d.cts +148 -0
- package/dist/core/journey.d.ts +28 -29
- package/dist/core/logger.d.cts +141 -0
- package/dist/core/logger.d.ts +45 -51
- package/dist/core/measure.d.cts +30 -0
- package/dist/core/measure.d.ts +21 -10
- package/dist/core/meter.d.cts +78 -0
- package/dist/core/meter.d.ts +38 -28
- package/dist/core/pipeline.d.cts +227 -0
- package/dist/core/pipeline.d.ts +114 -50
- package/dist/core/profile-buckets.d.cts +31 -0
- package/dist/core/profile-buckets.d.ts +31 -0
- package/dist/core/profiler.d.cts +218 -0
- package/dist/core/profiler.d.ts +218 -0
- package/dist/core/record.d.cts +190 -0
- package/dist/core/record.d.ts +67 -35
- package/dist/core/remote-rules.d.cts +17 -0
- package/dist/core/remote-rules.d.ts +7 -7
- package/dist/core/remote-sampling.d.cts +74 -0
- package/dist/core/remote-sampling.d.ts +24 -23
- package/dist/core/rotation.d.cts +75 -0
- package/dist/core/rotation.d.ts +75 -0
- package/dist/core/runtime.d.cts +765 -0
- package/dist/core/runtime.d.ts +430 -186
- package/dist/core/sampling.d.cts +86 -0
- package/dist/core/sampling.d.ts +22 -22
- package/dist/core/sender.d.cts +161 -0
- package/dist/core/sender.d.ts +80 -34
- package/dist/core/spans.d.cts +39 -0
- package/dist/core/spans.d.ts +6 -6
- package/dist/{deadline-BOjOxNHj.js → deadline-C4ccAuk5.js} +3 -6
- package/dist/deadline-C4ccAuk5.js.map +1 -0
- package/dist/deadline-CUGbto-y.cjs +2 -0
- package/dist/deadline-CUGbto-y.cjs.map +1 -0
- package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
- package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
- package/dist/debug-bundle-CRpYV_ui.js +35 -0
- package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
- package/dist/defineProperty-X1c4tIPD.cjs +1 -0
- package/dist/defineProperty-s2S8BXUc.js +35 -0
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.cjs.map +1 -1
- package/dist/doctor.d.cts +36 -0
- package/dist/doctor.d.ts +19 -6
- package/dist/doctor.js +180 -53
- package/dist/doctor.js.map +1 -1
- package/dist/error-like-B11pB4aL.js.map +1 -1
- package/dist/error-like-gGRx2s36.cjs.map +1 -1
- package/dist/errors-BE_EZV7Q.js +86 -0
- package/dist/errors-BE_EZV7Q.js.map +1 -0
- package/dist/errors-CNPbesMs.cjs +3 -0
- package/dist/errors-CNPbesMs.cjs.map +1 -0
- package/dist/factory-CTi0Is3F.js +404 -0
- package/dist/factory-CTi0Is3F.js.map +1 -0
- package/dist/factory-hRrH32v5.cjs +2 -0
- package/dist/factory-hRrH32v5.cjs.map +1 -0
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
- package/dist/fixed-window-Dq3MLUUv.js.map +1 -1
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/global-scope-D9I8s-oN.js.map +1 -1
- package/dist/guards-BlYGRK4l.js +10 -0
- package/dist/guards-BlYGRK4l.js.map +1 -0
- package/dist/guards-EjG3ahFp.cjs +2 -0
- package/dist/guards-EjG3ahFp.cjs.map +1 -0
- package/dist/{identity-DT5VmvXy.js → identity-DdhKgrpk.js} +11 -15
- package/dist/identity-DdhKgrpk.js.map +1 -0
- package/dist/identity-DlWRIuwy.cjs +2 -0
- package/dist/identity-DlWRIuwy.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +300 -0
- package/dist/index.d.ts +165 -141
- package/dist/index.js +1283 -1468
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
- package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
- package/dist/{indexeddb-storage-BJVtiQKm.js → indexeddb-storage-GHdl0t8A.js} +51 -47
- package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
- package/dist/interactions-CUkzK8sR.cjs +2 -0
- package/dist/interactions-CUkzK8sR.cjs.map +1 -0
- package/dist/{interactions-DTgKy_6K.js → interactions-DiFvCosX.js} +41 -49
- package/dist/interactions-DiFvCosX.js.map +1 -0
- package/dist/journey-B4Adltjm.cjs +2 -0
- package/dist/journey-B4Adltjm.cjs.map +1 -0
- package/dist/{journey-CuJrHzEg.js → journey-D2_sia57.js} +51 -53
- package/dist/journey-D2_sia57.js.map +1 -0
- package/dist/{library-console-C1m6g1BR.js → library-console-Btrzt814.js} +2 -2
- package/dist/library-console-Btrzt814.js.map +1 -0
- package/dist/{library-console-D2GY9Or6.cjs → library-console-CPW6bvZH.cjs} +2 -2
- package/dist/library-console-CPW6bvZH.cjs.map +1 -0
- package/dist/{library-request-BQBT9N9Q.js → library-request-BJ9PLRaD.js} +2 -2
- package/dist/library-request-BJ9PLRaD.js.map +1 -0
- package/dist/{library-request-1BX_UlaX.cjs → library-request-D7OvTxZV.cjs} +2 -2
- package/dist/library-request-D7OvTxZV.cjs.map +1 -0
- package/dist/{lifecycle-BaKx_-32.js → lifecycle-22CUCrc9.js} +21 -29
- package/dist/lifecycle-22CUCrc9.js.map +1 -0
- package/dist/lifecycle-IaAm1mOC.cjs +2 -0
- package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
- package/dist/{log-record-CAoGBBf3.js → log-record-BNiLfqtL.js} +8 -7
- package/dist/log-record-BNiLfqtL.js.map +1 -0
- package/dist/log-record-CkivuiEl.cjs +2 -0
- package/dist/log-record-CkivuiEl.cjs.map +1 -0
- package/dist/long-frames-BUUbXd-B.cjs +2 -0
- package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
- package/dist/long-frames-DNFaRnC3.js +62 -0
- package/dist/long-frames-DNFaRnC3.js.map +1 -0
- package/dist/models/batch.d.cts +57 -0
- package/dist/models/batch.d.ts +16 -17
- package/dist/models/bus.d.cts +158 -0
- package/dist/models/bus.d.ts +46 -26
- package/dist/models/config.d.cts +1540 -0
- package/dist/models/config.d.ts +692 -405
- package/dist/models/drop.d.cts +54 -0
- package/dist/models/drop.d.ts +29 -14
- package/dist/models/health.d.cts +148 -0
- package/dist/models/health.d.ts +119 -23
- package/dist/models/log-record.d.cts +61 -0
- package/dist/models/log-record.d.ts +13 -14
- package/dist/models/metric.d.cts +139 -0
- package/dist/models/metric.d.ts +94 -18
- package/dist/models/plugin.d.cts +47 -0
- package/dist/models/plugin.d.ts +16 -16
- package/dist/models/replay.d.cts +60 -0
- package/dist/models/replay.d.ts +60 -0
- package/dist/models/serializer.d.cts +23 -0
- package/dist/models/serializer.d.ts +3 -4
- package/dist/models/storage.d.cts +95 -0
- package/dist/models/storage.d.ts +17 -14
- package/dist/network-CGMLQ-mA.cjs +2 -0
- package/dist/network-CGMLQ-mA.cjs.map +1 -0
- package/dist/{network-DBNwApoF.js → network-on2zZT6H.js} +57 -57
- package/dist/network-on2zZT6H.js.map +1 -0
- package/dist/openfin-Bxelt0yg.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/otlp-BENHf3g9.cjs +2 -0
- package/dist/otlp-BENHf3g9.cjs.map +1 -0
- package/dist/{otlp-BTJdIa6F.js → otlp-DimfrRor.js} +22 -29
- package/dist/otlp-DimfrRor.js.map +1 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -1
- package/dist/patch-UdPz1ea8.js.map +1 -1
- package/dist/{platform-DkcuXwe-.js → platform-BaaFIPCU.js} +8 -8
- package/dist/platform-BaaFIPCU.js.map +1 -0
- package/dist/{platform-C2Ez5kDc.cjs → platform-CfA3-7sJ.cjs} +2 -2
- package/dist/platform-CfA3-7sJ.cjs.map +1 -0
- package/dist/profiler-BAZoh7A4.js +292 -0
- package/dist/profiler-BAZoh7A4.js.map +1 -0
- package/dist/profiler-D4tJpDRc.cjs +2 -0
- package/dist/profiler-D4tJpDRc.cjs.map +1 -0
- package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
- package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
- package/dist/profiler-frames-cJMx9wNM.js +78 -0
- package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
- package/dist/remote-rules-Dz9MRAsB.js +95 -0
- package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
- package/dist/remote-rules-_tY0zj5o.cjs +2 -0
- package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
- package/dist/replay-B3gFXIZd.cjs +2 -0
- package/dist/replay-B3gFXIZd.cjs.map +1 -0
- package/dist/replay-Ds-ANH34.js +310 -0
- package/dist/replay-Ds-ANH34.js.map +1 -0
- package/dist/reports-BDSe4dFH.cjs +2 -0
- package/dist/reports-BDSe4dFH.cjs.map +1 -0
- package/dist/{reports-TA-zInnq.js → reports-C-thq-bk.js} +25 -30
- package/dist/reports-C-thq-bk.js.map +1 -0
- package/dist/resource-timing-C576gFIQ.cjs +2 -0
- package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
- package/dist/{resource-timing-BLv3EA2A.js → resource-timing-eUl2dNgC.js} +20 -23
- package/dist/resource-timing-eUl2dNgC.js.map +1 -0
- package/dist/response-body-YdNl-HkR.cjs +3 -0
- package/dist/response-body-YdNl-HkR.cjs.map +1 -0
- package/dist/response-body-eoSQpLiH.js +331 -0
- package/dist/response-body-eoSQpLiH.js.map +1 -0
- package/dist/rotation-Cwct4ckk.js +94 -0
- package/dist/rotation-Cwct4ckk.js.map +1 -0
- package/dist/rotation-D4qUAHAu.cjs +2 -0
- package/dist/rotation-D4qUAHAu.cjs.map +1 -0
- package/dist/sampling-BlrI8jor.js +63 -0
- package/dist/sampling-BlrI8jor.js.map +1 -0
- package/dist/sampling-mXt4dstx.cjs +2 -0
- package/dist/sampling-mXt4dstx.cjs.map +1 -0
- package/dist/{sanitize-6ymPlVvP.js → sanitize-Ba0KqU06.js} +2 -2
- package/dist/sanitize-Ba0KqU06.js.map +1 -0
- package/dist/{sanitize-BAWzkZt0.cjs → sanitize-DQyiI_KY.cjs} +2 -2
- package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
- package/dist/sender-BdRuNVhF.cjs +2 -0
- package/dist/sender-BdRuNVhF.cjs.map +1 -0
- package/dist/sender-Dv8rAmpV.js +979 -0
- package/dist/sender-Dv8rAmpV.js.map +1 -0
- package/dist/storage/context-storage.d.cts +90 -0
- package/dist/storage/context-storage.d.ts +38 -37
- package/dist/storage/emergency-queue.d.cts +27 -0
- package/dist/storage/emergency-queue.d.ts +13 -13
- package/dist/storage/eviction.d.cts +40 -0
- package/dist/storage/eviction.d.ts +13 -13
- package/dist/storage/factory.d.cts +21 -0
- package/dist/storage/factory.d.ts +11 -10
- package/dist/storage/gap.d.cts +20 -0
- package/dist/storage/gap.d.ts +9 -9
- package/dist/storage/idb-driver.d.cts +93 -0
- package/dist/storage/idb-driver.d.ts +32 -33
- package/dist/storage/indexeddb-storage.d.cts +97 -0
- package/dist/storage/indexeddb-storage.d.ts +38 -31
- package/dist/storage/keys.d.cts +17 -0
- package/dist/storage/keys.d.ts +9 -9
- package/dist/storage/local-storage.d.cts +139 -0
- package/dist/storage/local-storage.d.ts +49 -42
- package/dist/storage/memory-storage.d.cts +73 -0
- package/dist/storage/memory-storage.d.ts +25 -25
- package/dist/storage/persistence.d.cts +8 -0
- package/dist/storage/persistence.d.ts +3 -3
- package/dist/storage/stored-context.d.cts +34 -0
- package/dist/storage/stored-context.d.ts +34 -0
- package/dist/stored-context-B2EzVuYm.js +51 -0
- package/dist/stored-context-B2EzVuYm.js.map +1 -0
- package/dist/stored-context-CXt7eHZL.cjs +2 -0
- package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
- package/dist/storm-C-zYSdDX.cjs +2 -0
- package/dist/storm-C-zYSdDX.cjs.map +1 -0
- package/dist/storm-DjKetLKZ.js +9 -0
- package/dist/storm-DjKetLKZ.js.map +1 -0
- package/dist/transport/compression.d.cts +7 -0
- package/dist/transport/compression.d.ts +2 -2
- package/dist/transport/custom-transport.d.cts +22 -0
- package/dist/transport/custom-transport.d.ts +6 -5
- package/dist/transport/errors.d.cts +31 -0
- package/dist/transport/errors.d.ts +7 -7
- package/dist/transport/exit-flush.d.cts +135 -0
- package/dist/transport/exit-flush.d.ts +62 -45
- package/dist/transport/headers.d.cts +8 -0
- package/dist/transport/headers.d.ts +4 -4
- package/dist/transport/http-transport.d.cts +116 -0
- package/dist/transport/http-transport.d.ts +48 -35
- package/dist/transport/memory-transport.d.cts +30 -0
- package/dist/transport/memory-transport.d.ts +8 -8
- package/dist/transport/response-body.d.cts +49 -0
- package/dist/transport/response-body.d.ts +49 -0
- package/dist/transport/retry-engine.d.cts +129 -0
- package/dist/transport/retry-engine.d.ts +62 -43
- package/dist/transport/serializers/ecs.d.cts +3 -0
- package/dist/transport/serializers/ecs.d.ts +2 -2
- package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
- package/dist/transport/serializers/otlp-metrics.d.ts +2 -2
- package/dist/transport/serializers/otlp-traces.d.cts +3 -0
- package/dist/transport/serializers/otlp-traces.d.ts +2 -2
- package/dist/transport/serializers/otlp.d.cts +47 -0
- package/dist/transport/serializers/otlp.d.ts +18 -18
- package/dist/transport/serializers/select.d.cts +38 -0
- package/dist/transport/serializers/select.d.ts +11 -11
- package/dist/transport/status-transport.d.cts +129 -0
- package/dist/transport/status-transport.d.ts +45 -28
- package/dist/transport/worker-client.d.cts +23 -0
- package/dist/transport/worker-client.d.ts +12 -3
- package/dist/transport/worker-entry.d.cts +5 -0
- package/dist/transport/worker-entry.d.ts +1 -1
- package/dist/transport/worker-protocol.d.cts +38 -0
- package/dist/transport/worker-protocol.d.ts +7 -5
- package/dist/transport/worker-server.d.cts +3 -0
- package/dist/transport/worker-server.d.ts +1 -1
- package/dist/transport/worker-transport.d.cts +10 -0
- package/dist/transport/worker-transport.d.ts +5 -4
- package/dist/types-BAerHgCq.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-CwcUhFOn.js → unclean-exit-DQD1cT7c.js} +23 -30
- package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
- package/dist/unclean-exit-py99ApzT.cjs +2 -0
- package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
- package/dist/unref-CU9Nyz_9.cjs +2 -0
- package/dist/unref-CU9Nyz_9.cjs.map +1 -0
- package/dist/unref-DgHPQeWv.js +7 -0
- package/dist/unref-DgHPQeWv.js.map +1 -0
- package/dist/{user-timing-_jZIhDKI.js → user-timing-BePqb1uN.js} +18 -18
- package/dist/user-timing-BePqb1uN.js.map +1 -0
- package/dist/user-timing-D6XTmpuM.cjs +2 -0
- package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
- package/dist/utils/console.d.cts +36 -0
- package/dist/utils/console.d.ts +6 -6
- package/dist/utils/deadline.d.cts +14 -0
- package/dist/utils/deadline.d.ts +4 -4
- package/dist/utils/error-like.d.cts +25 -0
- package/dist/utils/error-like.d.ts +7 -7
- package/dist/utils/fixed-window.d.cts +25 -0
- package/dist/utils/fixed-window.d.ts +9 -8
- package/dist/utils/global-scope.d.cts +20 -0
- package/dist/utils/global-scope.d.ts +8 -8
- package/dist/utils/guards.d.cts +14 -0
- package/dist/utils/guards.d.ts +10 -2
- package/dist/utils/identity.d.cts +109 -0
- package/dist/utils/identity.d.ts +20 -21
- package/dist/utils/library-console.d.cts +11 -0
- package/dist/utils/library-console.d.ts +4 -4
- package/dist/utils/library-request.d.cts +24 -0
- package/dist/utils/library-request.d.ts +10 -10
- package/dist/utils/lock.d.cts +24 -0
- package/dist/utils/lock.d.ts +11 -10
- package/dist/utils/openfin.d.cts +48 -0
- package/dist/utils/openfin.d.ts +5 -5
- package/dist/utils/patch.d.cts +9 -0
- package/dist/utils/patch.d.ts +6 -6
- package/dist/utils/platform.d.cts +62 -0
- package/dist/utils/platform.d.ts +15 -13
- package/dist/utils/sanitize.d.cts +52 -0
- package/dist/utils/sanitize.d.ts +5 -5
- package/dist/utils/sequence.d.cts +10 -0
- package/dist/utils/tracing.d.cts +158 -0
- package/dist/utils/tracing.d.ts +49 -42
- package/dist/utils/unref.d.cts +9 -0
- package/dist/utils/unref.d.ts +3 -3
- package/dist/web-socket-CoIUBM3C.cjs +2 -0
- package/dist/web-socket-CoIUBM3C.cjs.map +1 -0
- package/dist/{web-socket-CV7yIMnm.js → web-socket-DSHgDiZ6.js} +23 -28
- package/dist/web-socket-DSHgDiZ6.js.map +1 -0
- package/dist/web-vitals-4pWACwaR.js +71 -0
- package/dist/web-vitals-4pWACwaR.js.map +1 -0
- package/dist/web-vitals-__X7t4pj.cjs +2 -0
- package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
- package/dist/worker-protocol-QbvqNazn.cjs +2 -0
- package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
- package/dist/{worker-protocol-CrsdSDLn.js → worker-protocol-x074Rpet.js} +14 -11
- package/dist/worker-protocol-x074Rpet.js.map +1 -0
- package/dist/worker-server-CFe4nvos.cjs +2 -0
- package/dist/worker-server-CFe4nvos.cjs.map +1 -0
- package/dist/worker-server-iUVSjH8L.js +94 -0
- package/dist/worker-server-iUVSjH8L.js.map +1 -0
- package/dist/worker-transport-CRAX-09c.cjs +2 -0
- package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
- package/dist/worker-transport-Dy1KMA7t.js +190 -0
- package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
- package/llms.txt +397 -0
- package/package.json +55 -41
- package/dist/batch-C8OcWR2L.cjs.map +0 -1
- package/dist/batch-CL9uWYY3.js.map +0 -1
- package/dist/bus-BZ0GldpT.js +0 -660
- package/dist/bus-BZ0GldpT.js.map +0 -1
- package/dist/bus-VWlmM5xs.cjs +0 -2
- package/dist/bus-VWlmM5xs.cjs.map +0 -1
- package/dist/console-BPZCuSLc.cjs +0 -2
- package/dist/console-BPZCuSLc.cjs.map +0 -1
- package/dist/console-BeCF7n59.js +0 -82
- package/dist/console-BeCF7n59.js.map +0 -1
- package/dist/constants-DqKJH_MP.cjs +0 -2
- package/dist/constants-DqKJH_MP.cjs.map +0 -1
- package/dist/constants-zyrqveN4.js +0 -304
- package/dist/constants-zyrqveN4.js.map +0 -1
- package/dist/context-storage-BjzeBSxH.cjs +0 -2
- package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
- package/dist/context-storage-BzkoHzkQ.js +0 -51
- package/dist/context-storage-BzkoHzkQ.js.map +0 -1
- package/dist/deadline-BOjOxNHj.js.map +0 -1
- package/dist/deadline-XSnm95pg.cjs +0 -2
- package/dist/deadline-XSnm95pg.cjs.map +0 -1
- package/dist/debug-bundle-BzJNpbF0.cjs +0 -2
- package/dist/debug-bundle-BzJNpbF0.cjs.map +0 -1
- package/dist/debug-bundle-C7UkHZ-q.js +0 -25
- package/dist/debug-bundle-C7UkHZ-q.js.map +0 -1
- package/dist/emergency-queue-CNTRui5t.cjs +0 -2
- package/dist/emergency-queue-CNTRui5t.cjs.map +0 -1
- package/dist/emergency-queue-Zy6lNafo.js +0 -67
- package/dist/emergency-queue-Zy6lNafo.js.map +0 -1
- package/dist/errors-Dh7kef0i.js +0 -92
- package/dist/errors-Dh7kef0i.js.map +0 -1
- package/dist/errors-tfEr48bS.cjs +0 -3
- package/dist/errors-tfEr48bS.cjs.map +0 -1
- package/dist/factory-BonqI3NL.js +0 -276
- package/dist/factory-BonqI3NL.js.map +0 -1
- package/dist/factory-CJXVYp0R.cjs +0 -2
- package/dist/factory-CJXVYp0R.cjs.map +0 -1
- package/dist/guards-Cidk71ME.js +0 -7
- package/dist/guards-Cidk71ME.js.map +0 -1
- package/dist/guards-nJ70syPt.cjs +0 -2
- package/dist/guards-nJ70syPt.cjs.map +0 -1
- package/dist/identity-Cxgj6pZX.cjs +0 -2
- package/dist/identity-Cxgj6pZX.cjs.map +0 -1
- package/dist/identity-DT5VmvXy.js.map +0 -1
- package/dist/indexeddb-storage-BJVtiQKm.js.map +0 -1
- package/dist/indexeddb-storage-CIoW21Xd.cjs +0 -2
- package/dist/indexeddb-storage-CIoW21Xd.cjs.map +0 -1
- package/dist/interactions-DTgKy_6K.js.map +0 -1
- package/dist/interactions-fEN6FbVo.cjs +0 -2
- package/dist/interactions-fEN6FbVo.cjs.map +0 -1
- package/dist/journey-CuJrHzEg.js.map +0 -1
- package/dist/journey-pffMVMfa.cjs +0 -2
- package/dist/journey-pffMVMfa.cjs.map +0 -1
- package/dist/keys-BHhw_0Wh.cjs +0 -2
- package/dist/keys-BHhw_0Wh.cjs.map +0 -1
- package/dist/keys-BU9j5YqW.js +0 -16
- package/dist/keys-BU9j5YqW.js.map +0 -1
- package/dist/library-console-C1m6g1BR.js.map +0 -1
- package/dist/library-console-D2GY9Or6.cjs.map +0 -1
- package/dist/library-request-1BX_UlaX.cjs.map +0 -1
- package/dist/library-request-BQBT9N9Q.js.map +0 -1
- package/dist/lifecycle-2EtUaRpo.cjs +0 -2
- package/dist/lifecycle-2EtUaRpo.cjs.map +0 -1
- package/dist/lifecycle-BaKx_-32.js.map +0 -1
- package/dist/log-record-CAoGBBf3.js.map +0 -1
- package/dist/log-record-i9zOTkpQ.cjs +0 -2
- package/dist/log-record-i9zOTkpQ.cjs.map +0 -1
- package/dist/long-frames-BVg4i5SC.cjs +0 -2
- package/dist/long-frames-BVg4i5SC.cjs.map +0 -1
- package/dist/long-frames-Czk7IupC.js +0 -64
- package/dist/long-frames-Czk7IupC.js.map +0 -1
- package/dist/models/stats.d.ts +0 -11
- package/dist/network-DBNwApoF.js.map +0 -1
- package/dist/network-xbbuvG_6.cjs +0 -2
- package/dist/network-xbbuvG_6.cjs.map +0 -1
- package/dist/otlp-BDvFrLnc.cjs +0 -2
- package/dist/otlp-BDvFrLnc.cjs.map +0 -1
- package/dist/otlp-BTJdIa6F.js.map +0 -1
- package/dist/platform-C2Ez5kDc.cjs.map +0 -1
- package/dist/platform-DkcuXwe-.js.map +0 -1
- package/dist/remote-rules-Cfb4K-Nl.js +0 -98
- package/dist/remote-rules-Cfb4K-Nl.js.map +0 -1
- package/dist/remote-rules-vzvk7aKf.cjs +0 -2
- package/dist/remote-rules-vzvk7aKf.cjs.map +0 -1
- package/dist/reports-Dk2YhKIh.cjs +0 -2
- package/dist/reports-Dk2YhKIh.cjs.map +0 -1
- package/dist/reports-TA-zInnq.js.map +0 -1
- package/dist/resource-timing-BLv3EA2A.js.map +0 -1
- package/dist/resource-timing-Cysw1S1f.cjs +0 -2
- package/dist/resource-timing-Cysw1S1f.cjs.map +0 -1
- package/dist/sampling-C4VV-1MS.js +0 -60
- package/dist/sampling-C4VV-1MS.js.map +0 -1
- package/dist/sampling-Ckh2yW9k.cjs +0 -2
- package/dist/sampling-Ckh2yW9k.cjs.map +0 -1
- package/dist/sanitize-6ymPlVvP.js.map +0 -1
- package/dist/sanitize-BAWzkZt0.cjs.map +0 -1
- package/dist/select-ZF4by-lF.cjs +0 -3
- package/dist/select-ZF4by-lF.cjs.map +0 -1
- package/dist/select-xtQaenIi.js +0 -270
- package/dist/select-xtQaenIi.js.map +0 -1
- package/dist/sender-CiMHC9YG.js +0 -856
- package/dist/sender-CiMHC9YG.js.map +0 -1
- package/dist/sender-D5wBoXA8.cjs +0 -2
- package/dist/sender-D5wBoXA8.cjs.map +0 -1
- package/dist/storage-BA9RqRO-.cjs +0 -2
- package/dist/storage-BA9RqRO-.cjs.map +0 -1
- package/dist/storage-DZwed89z.js +0 -16
- package/dist/storage-DZwed89z.js.map +0 -1
- package/dist/storm-CYi9Swpx.cjs +0 -2
- package/dist/storm-CYi9Swpx.cjs.map +0 -1
- package/dist/storm-VR024_QN.js +0 -9
- package/dist/storm-VR024_QN.js.map +0 -1
- package/dist/unclean-exit-CwcUhFOn.js.map +0 -1
- package/dist/unclean-exit-DFUN57wY.cjs +0 -2
- package/dist/unclean-exit-DFUN57wY.cjs.map +0 -1
- package/dist/user-timing-C9kfRq3J.cjs +0 -2
- package/dist/user-timing-C9kfRq3J.cjs.map +0 -1
- package/dist/user-timing-_jZIhDKI.js.map +0 -1
- package/dist/utils/timer.d.ts +0 -19
- package/dist/web-socket-BWUoqBh8.cjs +0 -2
- package/dist/web-socket-BWUoqBh8.cjs.map +0 -1
- package/dist/web-socket-CV7yIMnm.js.map +0 -1
- package/dist/web-vitals-Bq4WFHQo.js +0 -52
- package/dist/web-vitals-Bq4WFHQo.js.map +0 -1
- package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
- package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
- package/dist/worker-protocol-Bai7GAIA.cjs +0 -2
- package/dist/worker-protocol-Bai7GAIA.cjs.map +0 -1
- package/dist/worker-protocol-CrsdSDLn.js.map +0 -1
- package/dist/worker-server-BrIYkfoa.cjs +0 -2
- package/dist/worker-server-BrIYkfoa.cjs.map +0 -1
- package/dist/worker-server-Dp5HYm4b.js +0 -83
- package/dist/worker-server-Dp5HYm4b.js.map +0 -1
- package/dist/worker-transport-Bwej4N2e.cjs +0 -2
- package/dist/worker-transport-Bwej4N2e.cjs.map +0 -1
- package/dist/worker-transport-D6jtgpqN.js +0 -199
- package/dist/worker-transport-D6jtgpqN.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline-CUGbto-y.cjs","names":["require_unref","DeadlineError","ms","withDeadline","expire","deadline","timer","reject","work"],"sources":["../src/utils/deadline.ts"],"sourcesContent":["// src/utils/deadline.ts\n//\n// Puts a deadline on a promise that could stay pending. A pending promise raises no\n// diagnostics event, so without a deadline its caller waits forever and keeps its slot.\n\nimport { unrefTimer } from \"./unref\";\n\n/** The error for a promise that didn't settle before its deadline. */\nexport class DeadlineError extends Error {\n /**\n * @param ms Deadline in milliseconds.\n */\n constructor(ms: number) {\n super(`The operation took longer than ${String(ms)} ms.`);\n this.name = \"DeadlineError\";\n }\n}\n\n/**\n * Rejects when a promise doesn't settle within a deadline.\n * @param work The promise to bound.\n * @param ms Deadline in milliseconds.\n * @returns The promise's value, or a rejection after the deadline.\n */\nexport function withDeadline<T>(work: Promise<T>, ms: number): Promise<T> {\n let expire: ReturnType<typeof setTimeout> | undefined;\n\n const deadline = new Promise<never>((_resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new DeadlineError(ms));\n }, ms);\n\n expire = timer;\n unrefTimer(timer);\n });\n\n // Clear the timer on success and on failure. Otherwise every storage call leaves an armed timer.\n return Promise.race([work, deadline]).finally(() => {\n clearTimeout(expire);\n });\n}\n"],"mappings":"A,wCAQA,IAAaC,EAAb,cAAmC,KAAM,CAIvC,YAAY,EAAY,CACtB,MAAM,kCAAkC,OAAOC,CAAE,EAAE,KAAK,EACxD,KAAK,KAAO,eACd,CACF,EAQA,SAAgBC,EAAgB,EAAkB,EAAwB,CACxE,IAAIC,EAEEC,EAAW,IAAI,SAAgB,EAAU,IAAW,CACxD,IAAMC,EAAQ,eAAiB,CAC7BC,EAAO,IAAIN,EAAcC,CAAE,CAAC,CAC9B,EAAGA,CAAE,EAEL,EAASI,EACTN,EAAA,EAAWM,CAAK,CAClB,CAAC,EAGD,OAAO,QAAQ,KAAK,CAACE,EAAMH,CAAQ,CAAC,CAAC,CAAC,YAAc,CAClD,aAAaD,CAAM,CACrB,CAAC,CACH,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./guards-EjG3ahFp.cjs"),t=require("./platform-CfA3-7sJ.cjs"),n=require("./sanitize-DQyiI_KY.cjs"),r=require("./config-DUs7uHHt.cjs");function i(n){return typeof n==`string`?/^[a-z][a-z\d+.-]*:\/\//i.test(n)?t.i(n,!1):n:Array.isArray(n)?n.map(i):e.n(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,i(t)])):n}function a(e,a,o){let s=e=>typeof e==`string`?t.i(e,!1):e,{capture:c,serializer:l}=e,u={...e,endpoint:s(e.endpoint),metricsEndpoint:s(e.metricsEndpoint),tracesEndpoint:s(e.tracesEndpoint),serializer:typeof l==`string`?l:l.name,redact:e.redact===r.t?`refused`:e.redact,processors:e.processors.map(e=>e===r.t?`refused`:e),capture:{...c,ignoreUrls:c.ignoreUrls.map(s),plugins:c.plugins.map(e=>e.name)},replay:{...e.replay,endpoint:s(e.replay.endpoint),headers:e.replay.headers!==null,plugins:e.replay.plugins.length,recordOptions:Object.keys(e.replay.recordOptions)}};return Reflect.deleteProperty(u,`headers`),i(n.n(u,a,o))}exports.configSummary=a;
|
|
2
|
+
//# sourceMappingURL=debug-bundle-BXIlwDKM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-bundle-BXIlwDKM.cjs","names":["recordedUrl","isObject","REFUSE_RECORDS","sanitize","require_guards","require_platform","require_sanitize","require_config","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","hook","capture","plugin","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport { REFUSE_RECORDS } from \"./config\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n // The stand-in for a bad hook value shows as \"refused\", so the bundle says why nothing sends.\n redact: config.redact === REFUSE_RECORDS ? \"refused\" : config.redact,\n processors: config.processors.map((hook) => (hook === REFUSE_RECORDS ? \"refused\" : hook)),\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":"A,sJAkBA,SAASQ,EAAU,EAAyB,CAa1C,OAZI,OAAOC,GAAU,SACZ,0BAA0B,KAAKA,CAAK,EAAIT,EAAAA,EAAYS,EAAO,EAAK,EAAIA,EAGzE,MAAM,QAAQA,CAAK,EACdA,EAAM,IAAID,CAAS,EAGxBP,EAAAA,EAASQ,CAAK,EACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,EAAKC,KAAW,CAACD,EAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,EAGzFF,CACT,CAUA,SAAgBG,EACd,EACA,EACA,EACyB,CAEzB,IAAMC,EAAO,GACX,OAAOJ,GAAU,SAAWT,EAAAA,EAAYS,EAAO,EAAK,EAAIA,EACpD,CAAE,UAAS,cAAeK,EAC1BC,EAAgC,CACpC,GAAGD,EACH,SAAUD,EAAIC,EAAO,QAAQ,EAC7B,gBAAiBD,EAAIC,EAAO,eAAe,EAC3C,eAAgBD,EAAIC,EAAO,cAAc,EAEzC,WAAY,OAAOE,GAAe,SAAWA,EAAaA,EAAW,KAErE,OAAQF,EAAO,SAAWZ,EAAAA,EAAiB,UAAYY,EAAO,OAC9D,WAAYA,EAAO,WAAW,IAAK,GAAUG,IAASf,EAAAA,EAAiB,UAAYe,CAAK,EACxF,QAAS,CACP,GAAGC,EACH,WAAYA,EAAQ,WAAW,IAAIL,CAAG,EACtC,QAASK,EAAQ,QAAQ,IAAK,GAAWC,EAAO,IAAI,CACtD,EAEA,OAAQ,CACN,GAAGL,EAAO,OACV,SAAUD,EAAIC,EAAO,OAAO,QAAQ,EACpC,QAASA,EAAO,OAAO,UAAY,KACnC,QAASA,EAAO,OAAO,QAAQ,OAC/B,cAAe,OAAO,KAAKA,EAAO,OAAO,aAAa,CACxD,CACF,EAIA,OAFA,QAAQ,eAAeC,EAAM,SAAS,EAE/BP,EAAUL,EAAAA,EAASY,EAAMK,EAAQC,CAAW,CAAC,CACtD,C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { n as e } from "./guards-BlYGRK4l.js";
|
|
2
|
+
import { i as t } from "./platform-BaaFIPCU.js";
|
|
3
|
+
import { n } from "./sanitize-Ba0KqU06.js";
|
|
4
|
+
import { t as r } from "./config-SgQcCP1_.js";
|
|
5
|
+
// src/core/debug-bundle.ts
|
|
6
|
+
function i(n) {
|
|
7
|
+
return typeof n == "string" ? /^[a-z][a-z\d+.-]*:\/\//i.test(n) ? t(n, !1) : n : Array.isArray(n) ? n.map(i) : e(n) ? Object.fromEntries(Object.entries(n).map(([e, t]) => [e, i(t)])) : n;
|
|
8
|
+
}
|
|
9
|
+
function a(e, a, o) {
|
|
10
|
+
let s = (e) => typeof e == "string" ? t(e, !1) : e, { capture: c, serializer: l } = e, u = {
|
|
11
|
+
...e,
|
|
12
|
+
endpoint: s(e.endpoint),
|
|
13
|
+
metricsEndpoint: s(e.metricsEndpoint),
|
|
14
|
+
tracesEndpoint: s(e.tracesEndpoint),
|
|
15
|
+
serializer: typeof l == "string" ? l : l.name,
|
|
16
|
+
redact: e.redact === r ? "refused" : e.redact,
|
|
17
|
+
processors: e.processors.map((e) => e === r ? "refused" : e),
|
|
18
|
+
capture: {
|
|
19
|
+
...c,
|
|
20
|
+
ignoreUrls: c.ignoreUrls.map(s),
|
|
21
|
+
plugins: c.plugins.map((e) => e.name)
|
|
22
|
+
},
|
|
23
|
+
replay: {
|
|
24
|
+
...e.replay,
|
|
25
|
+
endpoint: s(e.replay.endpoint),
|
|
26
|
+
headers: e.replay.headers !== null,
|
|
27
|
+
plugins: e.replay.plugins.length,
|
|
28
|
+
recordOptions: Object.keys(e.replay.recordOptions)
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return Reflect.deleteProperty(u, "headers"), i(n(u, a, o));
|
|
32
|
+
}
|
|
33
|
+
export { a as configSummary };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=debug-bundle-CRpYV_ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-bundle-CRpYV_ui.js","names":["isObject","recordedUrl","REFUSE_RECORDS","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","hook","capture","plugin","sanitize","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport { REFUSE_RECORDS } from \"./config\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n // The stand-in for a bad hook value shows as \"refused\", so the bundle says why nothing sends.\n redact: config.redact === REFUSE_RECORDS ? \"refused\" : config.redact,\n processors: config.processors.map((hook) => (hook === REFUSE_RECORDS ? \"refused\" : hook)),\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":";;;;;AAkBA,SAASG,EAAU,GAAyB;CAa1C,OAZI,OAAOC,KAAU,WACZ,0BAA0B,KAAKA,CAAK,IAAIH,EAAYG,GAAO,EAAK,IAAIA,IAGzE,MAAM,QAAQA,CAAK,IACdA,EAAM,IAAID,CAAS,IAGxBH,EAASI,CAAK,IACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,GAAKC,OAAW,CAACD,GAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,IAGzFF;AACT;AAUA,SAAgBG,EACd,GACA,GACA,GACyB;CAEzB,IAAMC,KAAO,MACX,OAAOJ,KAAU,WAAWH,EAAYG,GAAO,EAAK,IAAIA,GACpD,EAAE,YAAS,kBAAeK,GAC1BC,IAAgC;EACpC,GAAGD;EACH,UAAUD,EAAIC,EAAO,QAAQ;EAC7B,iBAAiBD,EAAIC,EAAO,eAAe;EAC3C,gBAAgBD,EAAIC,EAAO,cAAc;EAEzC,YAAY,OAAOE,KAAe,WAAWA,IAAaA,EAAW;EAErE,QAAQF,EAAO,WAAWP,IAAiB,YAAYO,EAAO;EAC9D,YAAYA,EAAO,WAAW,KAAK,MAAUG,MAASV,IAAiB,YAAYU,CAAK;EACxF,SAAS;GACP,GAAGC;GACH,YAAYA,EAAQ,WAAW,IAAIL,CAAG;GACtC,SAASK,EAAQ,QAAQ,KAAK,MAAWC,EAAO,IAAI;EACtD;EAEA,QAAQ;GACN,GAAGL,EAAO;GACV,UAAUD,EAAIC,EAAO,OAAO,QAAQ;GACpC,SAASA,EAAO,OAAO,YAAY;GACnC,SAASA,EAAO,OAAO,QAAQ;GAC/B,eAAe,OAAO,KAAKA,EAAO,OAAO,aAAa;EACxD;CACF;CAIA,OAFA,QAAQ,eAAeC,GAAM,SAAS,GAE/BP,EAAUY,EAASL,GAAMM,GAAQC,CAAW,CAAC;AACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
2
|
+
function e(t) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return e = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
5
|
+
return typeof e;
|
|
6
|
+
} : function(e) {
|
|
7
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
8
|
+
}, e(t);
|
|
9
|
+
}
|
|
10
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
11
|
+
function t(t, n) {
|
|
12
|
+
if (e(t) != "object" || !t) return t;
|
|
13
|
+
var r = t[Symbol.toPrimitive];
|
|
14
|
+
if (r !== void 0) {
|
|
15
|
+
var i = r.call(t, n || "default");
|
|
16
|
+
if (e(i) != "object") return i;
|
|
17
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
18
|
+
}
|
|
19
|
+
return (n === "string" ? String : Number)(t);
|
|
20
|
+
}
|
|
21
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
22
|
+
function n(n) {
|
|
23
|
+
var r = t(n, "string");
|
|
24
|
+
return e(r) == "symbol" ? r : r + "";
|
|
25
|
+
}
|
|
26
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
27
|
+
function r(e, t, r) {
|
|
28
|
+
return (t = n(t)) in e ? Object.defineProperty(e, t, {
|
|
29
|
+
value: r,
|
|
30
|
+
enumerable: !0,
|
|
31
|
+
configurable: !0,
|
|
32
|
+
writable: !0
|
|
33
|
+
}) : e[t] = r, e;
|
|
34
|
+
}
|
|
35
|
+
export { r as t };
|
package/dist/doctor.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-CqdJhTxH.cjs"),t=require("./compression-CvED_Jel.cjs"),n=require("./otlp-BENHf3g9.cjs");var r=1e4,i=0,a=1,o=2,s=`Usage: uiobs doctor <url> --origin <origin> [--replay] [--credentials include] [--header "Name: value"]. An origin has no path and no trailing slash. With --replay, the URL is a replay endpoint. With --credentials include, a * in a CORS header fails.`,c=`--header`,l=`--replay`,u=`--credentials`,d=`include`,f=5e6,p=5,m=`uiobs-doctor`,h=/^([\w!#$%&'*+.^`|~-]+): *([\x20-\x7e]+)$/,g=`<hidden>`,_=`Access-Control-Expose-Headers`,v=`Access-Control-Allow-Origin`,y=`Access-Control-Allow-Headers`,b=`Access-Control-Allow-Credentials`,x=`A browser refuses * with credentials: "include".`,S=`A browser does not read * as a wildcard with credentials: "include".`,C=`A browser never lets * cover authorization.`,w=`Add --credentials include to check that case.`,T=[e.ft,e.dt,e.ut,e.lt].map(e=>e.toLowerCase()),E=[...T,`origin`],D=[e.ht,e.pt].map(e=>e.toLowerCase()),O=`authorization`,k=[e.mt.toLowerCase()],A=[...k,...D];function j(){let t=crypto.randomUUID().replaceAll(`-`,``);return{timeUnixNano:`${String(Date.now())}000000`,traceId:t,spanId:t.slice(0,16),traceFlags:1,severityNumber:e.Vn.INFO,severityText:`INFO`,body:`uiobs doctor test record`,attributes:{},resource:{"service.name":m}}}async function M(e,t,n=r){try{return await fetch(e,{...t,redirect:`manual`,signal:AbortSignal.timeout(n)})}catch(e){let t=e instanceof Error?e.cause??e:e;return`The request failed. ${t instanceof Error?t.message:String(t)}`}}function N(e,t){return(e.headers.get(t)??``).toLowerCase().split(`,`).map(e=>e.trim())}function P(e,t,n,r){let i=N(e,t),a=r&&i.includes(`*`);return n.filter(e=>!i.includes(e)&&!(a&&e!==O))}var F=e=>e.ok?void 0:`The server returned ${String(e.status)}.`,I=e=>e.status===415?`The server returned ${String(e.status)} to a text/plain batch, as a stock OpenTelemetry Collector does. The library loses the exit batches of a page on another origin. Set headers in the app, or put a same-origin proxy in front of the server.`:void 0;function L(e,t,n,...r){let i=typeof t==`string`?t:r.map(e=>e(t)).find(e=>e!==void 0);return{rule:e,pass:i===void 0,detail:i??n}}function R(e,t,n,r){let i=Object.keys(n).map(e=>e.toLowerCase());return{url:e,origin:t,custom:n,requestHeaders:[...T,...i],credentials:r}}function z({origin:e,credentials:t}){return n=>{let r=n.headers.get(v);return r===`*`&&t?`${v} is *. ${x} It must be ${e}.`:r!==e&&r!==`*`?`${v} is ${String(r)}. It must allow ${e}.`:t?B(n):void 0}}var B=e=>{let t=e.headers.get(b);return t===`true`?void 0:`${b} is ${String(t)}. It must be true with credentials: "include".`};function V(e){return typeof e==`string`?null:e.headers.get(v)}function H(e,{credentials:t},n=x){return e&&!t?` ${n} ${w}`:``}function U(e,t,{credentials:n}){return n&&N(e,t).includes(`*`)?` ${S}`:``}function W(e,t,n){return typeof e!=`string`&&N(e,t).includes(`*`)&&P(e,t,n,!1).length>0}function G({url:e,origin:t,requestHeaders:n}){return M(e,{method:`OPTIONS`,headers:{Origin:t,"Access-Control-Request-Method":`POST`,"Access-Control-Request-Headers":n.join(`, `)}})}function K(e,t){let n=H(V(e)===`*`,t),r=H(W(e,y,t.requestHeaders),t,S);return[L(`preflight`,e,`The server permits POST from this origin.${n}`,F,z(t)),L(`allowed headers`,e,`The server allows each request header of the library.${r}`,e=>{let n=P(e,y,t.requestHeaders,!t.credentials);if(n.length===0)return;let r=U(e,y,t),i=n.includes(O)&&N(e,y).includes(`*`)?` ${C}`:``;return`${y} must include ${n.join(`, `)}.${r}${i}`})]}function q({url:t,origin:n,custom:r},i,a){return(o,s,c,l={})=>M(t,{method:`POST`,headers:{...r,Origin:n,[e.ft]:i,[e.ut]:o,[e.lt]:String(s),...l},body:c},a)}async function J(n,r,i){let a=await t.t(i);return a?n(r,0,a,{[e.dt]:e.tt}):`This Node version has no CompressionStream.`}async function Y(t,r,i={},a=!1){let o=R(t,r,i,a),s=z(o),c=await G(o),{body:l,contentType:u}=n.r.serialize([j()]),d=q(o,u),f=crypto.randomUUID(),p=await d(f,0,l),m=await d(f,1,l),h=await J(d,crypto.randomUUID(),l),g=new URL(t);g.searchParams.set(e.nn,crypto.randomUUID()),g.searchParams.set(e.rn,`pagehide`);let v=o.requestHeaders.length>T.length?void 0:await M(g.toString(),{method:`POST`,headers:{Origin:r,[e.ft]:e.V},body:l}),y=typeof p==`string`?[]:P(p,_,D,!o.credentials),b=y.length>0?` Optional headers stay hidden: ${y.join(`, `)}.`:``,x=H(W(p,_,A),o,S);return[...K(c,o),L(`test batch`,p,`The server accepted a test batch.${H(V(p)===`*`,o)}`,F,s),L(`exposed headers`,p,`The server exposes Retry-After.${b}${x}`,e=>P(e,_,k,!o.credentials).length===0?void 0:`${_} must include retry-after.${U(e,_,o)}`),L(`gzip`,h,`The server accepted a gzip batch.`,F),L(`deduplication`,m,`The server accepted a repeated batch id. A client cannot see if it stored the batch again.`,F),v===void 0?{rule:`beacon`,pass:!0,detail:`The library sends no beacon with custom headers. The tool sent no beacon.`}:L(`beacon`,v,`The server accepted a text/plain batch.`,I,F)]}async function X(t,n,r={},i=!1){let a=R(t,n,r,i),o=z(a),s=await G(a),c=crypto.randomUUID(),l={"replay.id":c,"session.id":crypto.randomUUID(),"tab.id":crypto.randomUUID(),"service.name":m},u=(e,t)=>{let n=[{type:p,timestamp:Date.now(),data:{tag:m,payload:t}}];return JSON.stringify({...l,sequence:e,bytes:JSON.stringify(n).length,events:n})},d=e=>`${c}-${String(e)}`,h=q(a,e.z),g=u(0,`uiobs doctor test event`),_=await h(d(0),0,g),v=await h(d(0),1,g),y=await J(h,d(1),u(1,`uiobs doctor gzip event`)),b=await q(a,e.z,e.pn)(d(2),0,u(2,`x`.repeat(f)));return[...K(s,a),L(`test segment`,_,`The server accepted a test segment.${H(V(_)===`*`,a)}`,F,o),L(`gzip`,y,`The server accepted a gzip segment.`,F),L(`large segment`,b,`The server accepted a segment of ${String(f)} bytes without gzip.`,e=>e.ok?void 0:`The server returned ${String(e.status)} for a segment of ${String(f)} bytes. The first segment of an upload has a full snapshot of the page. Raise the body limit of the server.`),L(`deduplication`,v,`The server accepted a repeated batch id. A client cannot see if it stored the segment again.`,F)]}function Z(e){let t=[],n=!1;for(let r=0;r<e.length;r+=2){if(e[r]===u&&e[r+1]===d){n=!0;continue}let i=e[r]===c?h.exec(e[r+1]):null;if(!i||E.includes(i[1].toLowerCase()))return;t.push([i[1],i[2]])}return{headers:Object.fromEntries(t),credentials:n}}function Q(e){if(!/^https?:\/\//i.test(e)||!URL.canParse(e))return!1;let{username:t,password:n}=new URL(e);return t===``&&n===``}var $=[`doctor`,`--origin`,l,c,u,d];function ee(e){if($.includes(e))return e;if(/^https?:\/\//i.test(e)&&URL.canParse(e)){let{origin:t,pathname:n}=new URL(e);return`${t}${n===`/`&&!e.endsWith(`/`)?``:n}`}return g}function te(e){return URL.canParse(e)&&new URL(e).origin===e}async function ne(e,t){let[n,r,c,u,...d]=e,f=d[0]===l,p=Z(f?d.slice(1):d);if(n!==`doctor`||c!==`--origin`||!Q(r)||!te(u)||!p)return t(s),t(`Received: ${JSON.stringify(e.map(ee))}`),o;let{headers:m,credentials:h}=p,g=await(f?X:Y)(r,u,m,h);for(let{rule:e,pass:n,detail:r}of g)t(`${n?`PASS`:`FAIL`} ${e}: ${r}`);return g.every(({pass:e})=>e)?i:a}exports.main=ne,exports.runDoctor=Y,exports.runReplayDoctor=X;
|
|
2
2
|
//# sourceMappingURL=doctor.cjs.map
|
package/dist/doctor.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.cjs","names":["HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","HEADER_DATE","SEVERITY_NUMBER","otlpSerializer","gzip","ENCODING_GZIP","require_constants","require_otlp","REQUEST_TIMEOUT_MS","EXIT_PASS","EXIT_FAIL","EXIT_USAGE","USAGE","EXPOSE_HEADERS","REQUEST_HEADERS","name","OPTIONAL_EXPOSED","testRecord","traceId","request","url","init","error","reason","absent","values","response","value","wanted","statusProblem","judge","tests","problem","answer","test","found","passed","runDoctor","originProblem","allowed","origin","preflight","post","contentType","id","attempt","extra","payload","batchId","first","body","repeated","compressed","zipped","hidden","note","missing","isHttpUrl","isOrigin","main","command","flag","args","print","results","pass","rule","detail"],"sources":["../src/doctor.ts"],"sourcesContent":["// src/doctor.ts\n//\n// Checks an ingest server against the ingest contract in the README. The `uiobs doctor` command\n// calls main(). The code uses web APIs only. The browser build replaces each \"node:\" import.\n\nimport {\n ENCODING_GZIP,\n HEADER_ATTEMPT,\n HEADER_BATCH_ID,\n HEADER_CONTENT_ENCODING,\n HEADER_CONTENT_TYPE,\n HEADER_DATE,\n HEADER_RETRY_AFTER,\n HEADER_SAMPLING,\n SEVERITY_NUMBER,\n} from \"./constants\";\nimport type { LogRecord } from \"./models/log-record\";\nimport { gzip } from \"./transport/compression\";\nimport { otlpSerializer } from \"./transport/serializers/otlp\";\n\n/** Maximum wait for one answer, in milliseconds. */\nconst REQUEST_TIMEOUT_MS = 10000;\n\n/** Exit code when each rule passes. */\nconst EXIT_PASS = 0;\n\n/** Exit code when a rule fails. */\nconst EXIT_FAIL = 1;\n\n/** Exit code of a wrong command. */\nconst EXIT_USAGE = 2;\n\n/** Text of a wrong command. */\nconst USAGE =\n \"Usage: uiobs doctor <url> --origin <origin>. An origin has no path and no trailing slash.\";\n\n/** Response header that lists the headers a page can read. */\nconst EXPOSE_HEADERS = \"Access-Control-Expose-Headers\";\n\n/** Request headers of the library. The server must allow each one. */\nconst REQUEST_HEADERS = [\n HEADER_CONTENT_TYPE,\n HEADER_CONTENT_ENCODING,\n HEADER_BATCH_ID,\n HEADER_ATTEMPT,\n].map((name) => name.toLowerCase());\n\n/** Response headers that only an optional feature reads. */\nconst OPTIONAL_EXPOSED = [HEADER_SAMPLING, HEADER_DATE].map((name) => name.toLowerCase());\n\n/** Result of one rule of the ingest contract. */\nexport interface DoctorResult {\n /** Rule name. */\n rule: string;\n /** True when the server meets the rule. */\n pass: boolean;\n /** Reason of the result. */\n detail: string;\n}\n\n/** An HTTP answer, or the text of a failed request. */\ntype Answer = Response | string;\n\n/** Gives the text of a problem, or undefined when the answer meets the test. */\ntype AnswerTest = (response: Response) => string | undefined;\n\n/** Builds the test record. The server stores it as an ordinary record. */\nfunction testRecord(): LogRecord {\n const traceId = crypto.randomUUID().replaceAll(\"-\", \"\");\n\n return {\n timeUnixNano: `${String(Date.now())}000000`,\n traceId,\n spanId: traceId.slice(0, 16),\n traceFlags: 1,\n severityNumber: SEVERITY_NUMBER.INFO,\n severityText: \"INFO\",\n body: \"uiobs doctor test record\",\n attributes: {},\n resource: { \"service.name\": \"uiobs-doctor\" },\n };\n}\n\n/** Sends one request. The result line reports a failure. The tool has no diagnostics instance. */\nasync function request(url: string, init: RequestInit): Promise<Answer> {\n try {\n // A browser refuses a preflight that redirects. A redirect can also name another host.\n return await fetch(url, {\n ...init,\n redirect: \"manual\",\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),\n });\n } catch (error) {\n // Node gives only \"fetch failed\". The cause holds the reason, for example ECONNREFUSED.\n const reason: unknown = error instanceof Error ? (error.cause ?? error) : error;\n\n return `The request failed. ${reason instanceof Error ? reason.message : String(reason)}`;\n }\n}\n\n/** Gives the wanted values that a comma-separated header omits. A wildcard has each value. */\nfunction absent(response: Response, name: string, wanted: readonly string[]): string[] {\n const values = (response.headers.get(name) ?? \"\")\n .toLowerCase()\n .split(\",\")\n .map((value) => value.trim());\n\n return values.includes(\"*\") ? [] : wanted.filter((value) => !values.includes(value));\n}\n\n/** Tests the status of an answer. */\nconst statusProblem: AnswerTest = (response) =>\n response.ok ? undefined : `The server returned ${String(response.status)}.`;\n\n/** Builds the result of one rule. The first problem is the detail. */\nfunction judge(rule: string, answer: Answer, passed: string, ...tests: AnswerTest[]): DoctorResult {\n const problem =\n typeof answer === \"string\"\n ? answer\n : tests.map((test) => test(answer)).find((found) => found !== undefined);\n\n return { rule, pass: problem === undefined, detail: problem ?? passed };\n}\n\n/**\n * Sends the requests of each rule, one at a time. Two requests with one batch id must not overlap.\n * @param url Ingest URL.\n * @param origin Origin of the app.\n * @returns One result for each rule.\n */\nexport async function runDoctor(url: string, origin: string): Promise<DoctorResult[]> {\n const originProblem: AnswerTest = (response) => {\n const allowed = response.headers.get(\"Access-Control-Allow-Origin\");\n\n return allowed === origin || allowed === \"*\"\n ? undefined\n : `Access-Control-Allow-Origin is ${String(allowed)}. It must allow ${origin}.`;\n };\n\n const preflight = await request(url, {\n method: \"OPTIONS\",\n headers: {\n Origin: origin,\n \"Access-Control-Request-Method\": \"POST\",\n \"Access-Control-Request-Headers\": REQUEST_HEADERS.join(\", \"),\n },\n });\n\n const { body, contentType } = otlpSerializer.serialize([testRecord()]);\n const post = (\n id: string,\n attempt: number,\n payload: BodyInit,\n extra: Record<string, string> = {},\n ): Promise<Answer> =>\n request(url, {\n method: \"POST\",\n headers: {\n Origin: origin,\n [HEADER_CONTENT_TYPE]: contentType,\n [HEADER_BATCH_ID]: id,\n [HEADER_ATTEMPT]: String(attempt),\n ...extra,\n },\n body: payload,\n });\n\n const batchId = crypto.randomUUID();\n const first = await post(batchId, 0, body);\n const repeated = await post(batchId, 1, body);\n const compressed = await gzip(body);\n const zipped = compressed\n ? await post(crypto.randomUUID(), 0, compressed, {\n [HEADER_CONTENT_ENCODING]: ENCODING_GZIP,\n })\n : \"This Node version has no CompressionStream.\";\n\n const hidden = typeof first === \"string\" ? [] : absent(first, EXPOSE_HEADERS, OPTIONAL_EXPOSED);\n const note = hidden.length > 0 ? ` Optional headers stay hidden: ${hidden.join(\", \")}.` : \"\";\n\n return [\n judge(\n \"preflight\",\n preflight,\n \"The server permits POST from this origin.\",\n statusProblem,\n originProblem,\n ),\n judge(\n \"allowed headers\",\n preflight,\n \"The server allows each request header of the library.\",\n (response) => {\n const missing = absent(response, \"Access-Control-Allow-Headers\", REQUEST_HEADERS);\n\n return missing.length > 0\n ? `Access-Control-Allow-Headers must include ${missing.join(\", \")}.`\n : undefined;\n },\n ),\n judge(\"test batch\", first, \"The server accepted a test batch.\", statusProblem, originProblem),\n judge(\"exposed headers\", first, `The server exposes Retry-After.${note}`, (response) =>\n absent(response, EXPOSE_HEADERS, [HEADER_RETRY_AFTER.toLowerCase()]).length > 0\n ? `${EXPOSE_HEADERS} must include retry-after.`\n : undefined,\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip batch.\", statusProblem),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the batch again.\",\n statusProblem,\n ),\n ];\n}\n\n/** Tests an HTTP URL. */\nfunction isHttpUrl(value: string): boolean {\n return /^https?:\\/\\//i.test(value) && URL.canParse(value);\n}\n\n/** Tests an exact browser origin. A path or a trailing slash does not match. */\nfunction isOrigin(value: string): boolean {\n return URL.canParse(value) && new URL(value).origin === value;\n}\n\n/**\n * Runs the command line tool.\n * @param args Arguments after the program name.\n * @param print Writes one line of output.\n * @returns The exit code.\n */\nexport async function main(\n args: readonly string[],\n print: (line: string) => void,\n): Promise<number> {\n const [command, url, flag, origin] = args;\n\n if (command !== \"doctor\" || flag !== \"--origin\" || !isHttpUrl(url) || !isOrigin(origin)) {\n print(USAGE);\n print(`Received: ${JSON.stringify(args)}`);\n return EXIT_USAGE;\n }\n\n const results = await runDoctor(url, origin);\n\n for (const { rule, pass, detail } of results) {\n print(`${pass ? \"PASS\" : \"FAIL\"} ${rule}: ${detail}`);\n }\n\n return results.every(({ pass }) => pass) ? EXIT_PASS : EXIT_FAIL;\n}\n"],"mappings":"A,gJAqBA,IAAMY,EAAqB,IAGrBC,EAAY,EAGZC,EAAY,EAGZC,EAAa,EAGbC,EACJ,4FAGIC,EAAiB,gCAGjBC,EAAkB,CACtBlB,EAAAA,GACAC,EAAAA,GACAC,EAAAA,GACAC,EAAAA,EACF,CAAC,CAAC,IAAK,GAASgB,EAAK,YAAY,CAAC,EAG5BC,EAAmB,CAAChB,EAAAA,GAAiBC,EAAAA,EAAW,CAAC,CAAC,IAAK,GAASc,EAAK,YAAY,CAAC,EAmBxF,SAASE,GAAwB,CAC/B,IAAMC,EAAU,OAAO,WAAW,CAAC,CAAC,WAAW,IAAK,EAAE,EAEtD,MAAO,CACL,aAAc,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE,QACpC,UACA,OAAQA,EAAQ,MAAM,EAAG,EAAE,EAC3B,WAAY,EACZ,eAAgBhB,EAAAA,GAAgB,KAChC,aAAc,OACd,KAAM,2BACN,WAAY,CAAC,EACb,SAAU,CAAE,eAAgB,cAAe,CAC7C,CACF,CAGA,eAAeiB,EAAQ,EAAa,EAAoC,CACtE,GAAI,CAEF,OAAO,MAAM,MAAMC,EAAK,CACtB,GAAGC,EACH,SAAU,SACV,OAAQ,YAAY,QAAQb,C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AAK,IAAI,SAASA,CAAK,CAC1D,CAGA,SAAS+B,EAAS,EAAwB,CACxC,OAAO,IAAI,SAAS/B,CAAK,GAAK,IAAI,IAAIA,CAAK,CAAC,CAAC,SAAWA,CAC1D,CAQA,eAAsBgC,EACpB,EACA,EACiB,CACjB,GAAM,CAACC,EAASxC,EAAKyC,EAAMrB,GAAUsB,EAErC,GAAIF,IAAY,UAAYC,IAAS,YAAc,CAACJ,EAAUrC,CAAG,GAAK,CAACsC,EAASlB,CAAM,EAGpF,OAFAuB,EAAMnD,CAAK,EACXmD,EAAM,aAAa,KAAK,UAAUD,CAAI,GAAG,EAClCnD,EAGT,IAAMqD,EAAU,MAAM3B,EAAUjB,EAAKoB,CAAM,EAE3C,IAAK,GAAM,CAAE,OAAM,OAAM,YAAYwB,EACnCD,EAAM,GAAGE,EAAO,OAAS,OAAO,GAAGC,EAAK,IAAIC,GAAQ,EAGtD,OAAOH,EAAQ,OAAO,CAAE,UAAWC,CAAI,EAAIxD,EAAYC,CACzD,C"}
|
|
1
|
+
{"version":3,"file":"doctor.cjs","names":["HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","HEADER_DATE","HEADER_RETRY_AFTER","SEVERITY_NUMBER","gzip","ENCODING_GZIP","otlpSerializer","QUERY_PARAM_BATCH_ID","QUERY_PARAM_EXIT_REASON","CONTENT_TYPE_TEXT_PLAIN","CONTENT_TYPE_JSON","LIBRARY_TIMEOUT_MS","require_constants","require_compression","require_otlp","REQUEST_TIMEOUT_MS","EXIT_PASS","EXIT_FAIL","EXIT_USAGE","USAGE","HEADER_FLAG","REPLAY_FLAG","CREDENTIALS_FLAG","CREDENTIALS_INCLUDE","LARGE_EVENT_CHARS","CUSTOM_EVENT","DOCTOR_NAME","HEADER_PATTERN","HIDDEN","EXPOSE_HEADERS","ALLOW_ORIGIN","ALLOW_HEADERS","ALLOW_CREDENTIALS","STAR_REFUSED","STAR_PLAIN","STAR_AUTHORIZATION","STAR_HINT","REQUEST_HEADERS","name","RESERVED_HEADERS","OPTIONAL_EXPOSED","NON_WILDCARD_HEADER","REQUIRED_EXPOSED","WANTED_EXPOSED","testRecord","traceId","request","url","init","timeoutMs","error","reason","valuesOf","response","value","absent","values","star","wildcard","wanted","statusProblem","mediaTypeProblem","judge","tests","problem","answer","test","found","passed","targetOf","customNames","custom","originTest","allowed","credentials","origin","allowsCredentials","allowedOrigin","starNote","earnedByStar","starWhy","coveredByStar","sendPreflight","requestHeaders","preflightResults","originNote","preflight","target","headersNote","missing","why","authorization","poster","contentType","id","attempt","extra","payload","postZipped","compressed","body","post","runDoctor","originProblem","batchId","first","repeated","zipped","beaconUrl","beacon","hidden","hiddenNote","exposedNote","runReplayDoctor","replayId","head","segment","events","text","idOf","sequence","small","large","parseOptions","pairs","index","args","match","isHttpUrl","username","password","SHOWN_WORDS","shownArgument","arg","pathname","isOrigin","main","command","flag","rest","replay","options","print","results","headers","pass","rule","detail"],"sources":["../src/doctor.ts"],"sourcesContent":["// src/doctor.ts\n//\n// Checks an ingest server, or a replay endpoint, against its contract in docs/ingest-server.md.\n// The `uiobs doctor` command calls main(). Only web APIs are used here, and the browser build\n// replaces every \"node:\" import.\n\nimport {\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_TEXT_PLAIN,\n ENCODING_GZIP,\n HEADER_ATTEMPT,\n HEADER_BATCH_ID,\n HEADER_CONTENT_ENCODING,\n HEADER_CONTENT_TYPE,\n HEADER_DATE,\n HEADER_RETRY_AFTER,\n HEADER_SAMPLING,\n HTTP_UNSUPPORTED_MEDIA_TYPE,\n QUERY_PARAM_BATCH_ID,\n QUERY_PARAM_EXIT_REASON,\n REQUEST_TIMEOUT_MS as LIBRARY_TIMEOUT_MS,\n SEVERITY_NUMBER,\n} from \"./constants\";\nimport type { LogRecord } from \"./models/log-record\";\nimport { gzip } from \"./transport/compression\";\nimport { otlpSerializer } from \"./transport/serializers/otlp\";\n\n/** How long to wait for one answer, in milliseconds. */\nconst REQUEST_TIMEOUT_MS = 10000;\n\n/** Exit code when every rule passes. */\nconst EXIT_PASS = 0;\n\n/** Exit code when a rule fails. */\nconst EXIT_FAIL = 1;\n\n/** Exit code for a wrong command. */\nconst EXIT_USAGE = 2;\n\n/** Printed for a wrong command. */\nconst USAGE =\n 'Usage: uiobs doctor <url> --origin <origin> [--replay] [--credentials include] [--header \"Name: value\"]. An origin has no path and no trailing slash. With --replay, the URL is a replay endpoint. With --credentials include, a * in a CORS header fails.';\n\n/** Adds a request header, e.g. an Authorization header. */\nconst HEADER_FLAG = \"--header\";\n\n/** Says that the URL is a replay endpoint, so the tool sends segments instead of batches. */\nconst REPLAY_FLAG = \"--replay\";\n\n/** Says that the app sets `credentials: \"include\"`, so a browser refuses a * in a CORS header. */\nconst CREDENTIALS_FLAG = \"--credentials\";\n\n/** The only value of CREDENTIALS_FLAG. */\nconst CREDENTIALS_INCLUDE = \"include\";\n\n/**\n * Size of the event in the large test segment, in characters. The first segment of a real\n * upload holds a full snapshot, and one of a page with 35,000 table cells measured 4.7 MB.\n */\nconst LARGE_EVENT_CHARS = 5_000_000;\n\n/** The recorder's custom event type. A player skips a custom event it doesn't know. */\nconst CUSTOM_EVENT = 5;\n\n/** Marks everything the tool stores, so an operator can find and delete it. */\nconst DOCTOR_NAME = \"uiobs-doctor\";\n\n/** A header name, a colon, then a value of printable ASCII. */\nconst HEADER_PATTERN = /^([\\w!#$%&'*+.^`|~-]+): *([\\x20-\\x7e]+)$/;\n\n/** Printed in place of any argument that might contain a secret. */\nconst HIDDEN = \"<hidden>\";\n\n/** Response header that lists the headers a page can read. */\nconst EXPOSE_HEADERS = \"Access-Control-Expose-Headers\";\n\n/** Response header that names the origin that may read the answer. */\nconst ALLOW_ORIGIN = \"Access-Control-Allow-Origin\";\n\n/** Response header of a preflight that lists the request headers the server accepts. */\nconst ALLOW_HEADERS = \"Access-Control-Allow-Headers\";\n\n/** Response header that lets a browser send and read an answer with credentials. */\nconst ALLOW_CREDENTIALS = \"Access-Control-Allow-Credentials\";\n\n/** Why a * in Access-Control-Allow-Origin fails with credentials. */\nconst STAR_REFUSED = 'A browser refuses * with credentials: \"include\".';\n\n/** Why a * in a list of header names fails with credentials. */\nconst STAR_PLAIN = 'A browser does not read * as a wildcard with credentials: \"include\".';\n\n/** Why a * in Access-Control-Allow-Headers fails for Authorization, with or without credentials. */\nconst STAR_AUTHORIZATION = \"A browser never lets * cover authorization.\";\n\n/** Ends the note of a PASS line that only a * earned, so the run without credentials says so. */\nconst STAR_HINT = \"Add --credentials include to check that case.\";\n\n/** The library's request headers. The server must allow every one of them. */\nconst REQUEST_HEADERS = [\n HEADER_CONTENT_TYPE,\n HEADER_CONTENT_ENCODING,\n HEADER_BATCH_ID,\n HEADER_ATTEMPT,\n].map((name) => name.toLowerCase());\n\n/** Headers the tool sets itself. A custom header can't reuse one of these names. */\nconst RESERVED_HEADERS = [...REQUEST_HEADERS, \"origin\"];\n\n/** Response headers that only an optional feature reads. */\nconst OPTIONAL_EXPOSED = [HEADER_SAMPLING, HEADER_DATE].map((name) => name.toLowerCase());\n\n/** The one request header that a * in Access-Control-Allow-Headers never covers. */\nconst NON_WILDCARD_HEADER = \"authorization\";\n\n/** The response header that the library can't work without when it is hidden. */\nconst REQUIRED_EXPOSED = [HEADER_RETRY_AFTER.toLowerCase()];\n\n/** Every response header that the library reads. */\nconst WANTED_EXPOSED = [...REQUIRED_EXPOSED, ...OPTIONAL_EXPOSED];\n\n/** The result of one ingest contract rule. */\nexport interface DoctorResult {\n /** Rule name. */\n rule: string;\n /** True when the server meets the rule. */\n pass: boolean;\n /** Why the rule passed or failed. */\n detail: string;\n}\n\n/** An HTTP answer, or the text of a failed request. */\ntype Answer = Response | string;\n\n/** Returns a description of the problem, or undefined when the answer passes the test. */\ntype AnswerTest = (response: Response) => string | undefined;\n\n/** Builds the test record. The server stores it like any other record. */\nfunction testRecord(): LogRecord {\n const traceId = crypto.randomUUID().replaceAll(\"-\", \"\");\n\n return {\n timeUnixNano: `${String(Date.now())}000000`,\n traceId,\n spanId: traceId.slice(0, 16),\n traceFlags: 1,\n severityNumber: SEVERITY_NUMBER.INFO,\n severityText: \"INFO\",\n body: \"uiobs doctor test record\",\n attributes: {},\n resource: { \"service.name\": DOCTOR_NAME },\n };\n}\n\n/** Sends one request. A failure shows up in the result line, as the tool has no diagnostics. */\nasync function request(\n url: string,\n init: RequestInit,\n timeoutMs = REQUEST_TIMEOUT_MS,\n): Promise<Answer> {\n try {\n // A browser refuses a preflight that redirects, and a redirect can also name another host.\n return await fetch(url, {\n ...init,\n redirect: \"manual\",\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n // Node only says \"fetch failed\". The cause holds the real reason, for example ECONNREFUSED.\n const reason: unknown =\n error instanceof Error ? ((error as Error & { cause?: unknown }).cause ?? error) : error;\n\n return `The request failed. ${reason instanceof Error ? reason.message : String(reason)}`;\n }\n}\n\n/** Returns the lowercase values of a comma-separated response header. */\nfunction valuesOf(response: Response, name: string): string[] {\n return (response.headers.get(name) ?? \"\")\n .toLowerCase()\n .split(\",\")\n .map((value) => value.trim());\n}\n\n/**\n * Returns the wanted values a comma-separated header leaves out. With wildcard, a * covers them\n * all but Authorization, which the Fetch standard never lets a * cover. A run with credentials\n * passes false, because a browser reads * as a plain name then.\n */\nfunction absent(\n response: Response,\n name: string,\n wanted: readonly string[],\n wildcard: boolean,\n): string[] {\n const values = valuesOf(response, name);\n const star = wildcard && values.includes(\"*\");\n\n return wanted.filter(\n (value) => !values.includes(value) && !(star && value !== NON_WILDCARD_HEADER),\n );\n}\n\n/** Checks an answer's status. */\nconst statusProblem: AnswerTest = (response) =>\n response.ok ? undefined : `The server returned ${String(response.status)}.`;\n\n/**\n * Names the collector case for a 415 answer to the beacon batch, because the bare status doesn't\n * say that only the exit batches are lost or how to fix it.\n */\nconst mediaTypeProblem: AnswerTest = (response) =>\n response.status === HTTP_UNSUPPORTED_MEDIA_TYPE\n ? `The server returned ${String(response.status)} to a text/plain batch, as a stock OpenTelemetry Collector does. The library loses the exit batches of a page on another origin. Set headers in the app, or put a same-origin proxy in front of the server.`\n : undefined;\n\n/** Builds the result for one rule. The first problem found becomes the detail. */\nfunction judge(rule: string, answer: Answer, passed: string, ...tests: AnswerTest[]): DoctorResult {\n const problem =\n typeof answer === \"string\"\n ? answer\n : tests.map((test) => test(answer)).find((found) => found !== undefined);\n\n return { rule, pass: problem === undefined, detail: problem ?? passed };\n}\n\n/** One endpoint under test: where it is, who calls it and with which headers. */\ninterface Target {\n /** Endpoint URL. */\n url: string;\n /** The app's origin. */\n origin: string;\n /** The app's headers for each POST, e.g. an Authorization header. */\n custom: Readonly<Record<string, string>>;\n /** Lowercase names of every header a POST carries. The preflight asks for them. */\n requestHeaders: string[];\n /** True with `--credentials include`. A browser then refuses a * in a CORS header. */\n credentials: boolean;\n}\n\n/** Sends one POST the way the library does. Extra headers go on top. */\ntype Post = (\n id: string,\n attempt: number,\n payload: BodyInit,\n extra?: Record<string, string>,\n) => Promise<Answer>;\n\n/** Builds the target for one run. */\nfunction targetOf(\n url: string,\n origin: string,\n custom: Readonly<Record<string, string>>,\n credentials: boolean,\n): Target {\n const customNames = Object.keys(custom).map((name) => name.toLowerCase());\n\n return {\n url,\n origin,\n custom,\n requestHeaders: [...REQUEST_HEADERS, ...customNames],\n credentials,\n };\n}\n\n/** Builds the test that an answer lets the app's origin read it. */\nfunction originTest({ origin, credentials }: Target): AnswerTest {\n return (response) => {\n const allowed = response.headers.get(ALLOW_ORIGIN);\n\n if (allowed === \"*\" && credentials) {\n return `${ALLOW_ORIGIN} is *. ${STAR_REFUSED} It must be ${origin}.`;\n }\n\n if (allowed !== origin && allowed !== \"*\") {\n return `${ALLOW_ORIGIN} is ${String(allowed)}. It must allow ${origin}.`;\n }\n\n // A browser rejects a credentialed answer without this header. The library then sees a\n // network error and sends the batch again.\n return credentials ? allowsCredentials(response) : undefined;\n };\n}\n\n/** Checks that an answer lets the browser send and read credentials. */\nconst allowsCredentials: AnswerTest = (response) => {\n const allowed = response.headers.get(ALLOW_CREDENTIALS);\n\n return allowed === \"true\"\n ? undefined\n : `${ALLOW_CREDENTIALS} is ${String(allowed)}. It must be true with credentials: \"include\".`;\n};\n\n/** Returns the origin an answer allows, or null for a failed request or a missing header. */\nfunction allowedOrigin(answer: Answer): string | null {\n return typeof answer === \"string\" ? null : answer.headers.get(ALLOW_ORIGIN);\n}\n\n/**\n * Returns the note for a PASS that only a * earned. With credentials the rule fails on that *,\n * so the note is for the run without them.\n */\nfunction starNote(earnedByStar: boolean, { credentials }: Target, reason = STAR_REFUSED): string {\n return earnedByStar && !credentials ? ` ${reason} ${STAR_HINT}` : \"\";\n}\n\n/** Returns the reason that a * doesn't help a list of header names with credentials, or \"\". */\nfunction starWhy(response: Response, name: string, { credentials }: Target): string {\n return credentials && valuesOf(response, name).includes(\"*\") ? ` ${STAR_PLAIN}` : \"\";\n}\n\n/** True when a list of header names passes only because of its *: it has one and misses a name. */\nfunction coveredByStar(answer: Answer, name: string, wanted: readonly string[]): boolean {\n return (\n typeof answer !== \"string\" &&\n valuesOf(answer, name).includes(\"*\") &&\n absent(answer, name, wanted, false).length > 0\n );\n}\n\n/** Sends the preflight a browser sends before the library's POST. */\nfunction sendPreflight({ url, origin, requestHeaders }: Target): Promise<Answer> {\n return request(url, {\n method: \"OPTIONS\",\n headers: {\n Origin: origin,\n \"Access-Control-Request-Method\": \"POST\",\n \"Access-Control-Request-Headers\": requestHeaders.join(\", \"),\n },\n });\n}\n\n/** Builds the two results every preflight gives. */\nfunction preflightResults(preflight: Answer, target: Target): DoctorResult[] {\n const originNote = starNote(allowedOrigin(preflight) === \"*\", target);\n const headersByStar = coveredByStar(preflight, ALLOW_HEADERS, target.requestHeaders);\n const headersNote = starNote(headersByStar, target, STAR_PLAIN);\n\n return [\n judge(\n \"preflight\",\n preflight,\n `The server permits POST from this origin.${originNote}`,\n statusProblem,\n originTest(target),\n ),\n judge(\n \"allowed headers\",\n preflight,\n `The server allows each request header of the library.${headersNote}`,\n (response) => {\n const missing = absent(response, ALLOW_HEADERS, target.requestHeaders, !target.credentials);\n if (missing.length === 0) {\n return undefined;\n }\n\n const why = starWhy(response, ALLOW_HEADERS, target);\n const authorization =\n missing.includes(NON_WILDCARD_HEADER) && valuesOf(response, ALLOW_HEADERS).includes(\"*\")\n ? ` ${STAR_AUTHORIZATION}`\n : \"\";\n\n return `${ALLOW_HEADERS} must include ${missing.join(\", \")}.${why}${authorization}`;\n },\n ),\n ];\n}\n\n/** Builds the POST function for one target and content type. */\nfunction poster({ url, origin, custom }: Target, contentType: string, timeoutMs?: number): Post {\n return (id, attempt, payload, extra = {}) =>\n request(\n url,\n {\n method: \"POST\",\n headers: {\n ...custom,\n Origin: origin,\n [HEADER_CONTENT_TYPE]: contentType,\n [HEADER_BATCH_ID]: id,\n [HEADER_ATTEMPT]: String(attempt),\n ...extra,\n },\n body: payload,\n },\n timeoutMs,\n );\n}\n\n/** Sends a body with gzip. Gives the text of the problem if this Node can't compress. */\nasync function postZipped(post: Post, id: string, body: string): Promise<Answer> {\n const compressed = await gzip(body);\n\n return compressed\n ? post(id, 0, compressed, { [HEADER_CONTENT_ENCODING]: ENCODING_GZIP })\n : \"This Node version has no CompressionStream.\";\n}\n\n/**\n * Runs each rule's requests one at a time. Two requests with the same batch id must not overlap.\n * @param url Ingest URL.\n * @param origin The app's origin.\n * @param custom The app's headers for each batch, e.g. an Authorization header.\n * @param credentials True when the app sets `credentials: \"include\"`. A * in a CORS header then\n * fails, and the preflight must allow credentials.\n * @returns One result per rule.\n */\nexport async function runDoctor(\n url: string,\n origin: string,\n custom: Readonly<Record<string, string>> = {},\n credentials = false,\n): Promise<DoctorResult[]> {\n const target = targetOf(url, origin, custom, credentials);\n const originProblem = originTest(target);\n const preflight = await sendPreflight(target);\n\n const { body, contentType } = otlpSerializer.serialize([testRecord()]);\n const post = poster(target, contentType);\n\n const batchId = crypto.randomUUID();\n const first = await post(batchId, 0, body);\n const repeated = await post(batchId, 1, body);\n const zipped = await postZipped(post, crypto.randomUUID(), body);\n\n // sendBeacon can't set headers, so the id and the reason go in the query, like the exit flush.\n const beaconUrl = new URL(url);\n beaconUrl.searchParams.set(QUERY_PARAM_BATCH_ID, crypto.randomUUID());\n beaconUrl.searchParams.set(QUERY_PARAM_EXIT_REASON, \"pagehide\");\n\n // With custom headers the library's exit flush uses a keepalive fetch instead of a beacon.\n const beacon =\n target.requestHeaders.length > REQUEST_HEADERS.length\n ? undefined\n : await request(beaconUrl.toString(), {\n method: \"POST\",\n headers: { Origin: origin, [HEADER_CONTENT_TYPE]: CONTENT_TYPE_TEXT_PLAIN },\n body,\n });\n\n const hidden =\n typeof first === \"string\"\n ? []\n : absent(first, EXPOSE_HEADERS, OPTIONAL_EXPOSED, !target.credentials);\n const hiddenNote =\n hidden.length > 0 ? ` Optional headers stay hidden: ${hidden.join(\", \")}.` : \"\";\n const exposedNote = starNote(\n coveredByStar(first, EXPOSE_HEADERS, WANTED_EXPOSED),\n target,\n STAR_PLAIN,\n );\n\n return [\n ...preflightResults(preflight, target),\n judge(\n \"test batch\",\n first,\n `The server accepted a test batch.${starNote(allowedOrigin(first) === \"*\", target)}`,\n statusProblem,\n originProblem,\n ),\n judge(\n \"exposed headers\",\n first,\n `The server exposes Retry-After.${hiddenNote}${exposedNote}`,\n (response) => {\n if (absent(response, EXPOSE_HEADERS, REQUIRED_EXPOSED, !target.credentials).length === 0) {\n return undefined;\n }\n\n const why = starWhy(response, EXPOSE_HEADERS, target);\n\n return `${EXPOSE_HEADERS} must include retry-after.${why}`;\n },\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip batch.\", statusProblem),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the batch again.\",\n statusProblem,\n ),\n beacon === undefined\n ? {\n rule: \"beacon\",\n pass: true,\n detail: \"The library sends no beacon with custom headers. The tool sent no beacon.\",\n }\n : judge(\n \"beacon\",\n beacon,\n \"The server accepted a text/plain batch.\",\n mediaTypeProblem,\n statusProblem,\n ),\n ];\n}\n\n/**\n * Checks a replay endpoint the way runDoctor() checks an ingest server. A segment has its own\n * body and its own batch id form, and its first one can be several megabytes.\n * @param url Replay endpoint URL, the value of replay.endpoint.\n * @param origin The app's origin.\n * @param custom The app's replay.headers, e.g. an Authorization header.\n * @param credentials True when the app sets `credentials: \"include\"`. See runDoctor().\n * @returns One result per rule.\n */\nexport async function runReplayDoctor(\n url: string,\n origin: string,\n custom: Readonly<Record<string, string>> = {},\n credentials = false,\n): Promise<DoctorResult[]> {\n const target = targetOf(url, origin, custom, credentials);\n const originProblem = originTest(target);\n const preflight = await sendPreflight(target);\n\n const replayId = crypto.randomUUID();\n const head = {\n \"replay.id\": replayId,\n \"session.id\": crypto.randomUUID(),\n \"tab.id\": crypto.randomUUID(),\n \"service.name\": DOCTOR_NAME,\n };\n // The body the uploader sends: the ids, the sequence, the JSON length of the events, and the\n // events themselves.\n const segment = (sequence: number, text: string): string => {\n const events = [\n { type: CUSTOM_EVENT, timestamp: Date.now(), data: { tag: DOCTOR_NAME, payload: text } },\n ];\n\n return JSON.stringify({ ...head, sequence, bytes: JSON.stringify(events).length, events });\n };\n // The uploader's batch id is the replay id plus the sequence.\n const idOf = (sequence: number): string => `${replayId}-${String(sequence)}`;\n const post = poster(target, CONTENT_TYPE_JSON);\n const small = segment(0, \"uiobs doctor test event\");\n\n const first = await post(idOf(0), 0, small);\n const repeated = await post(idOf(0), 1, small);\n const zipped = await postZipped(post, idOf(1), segment(1, \"uiobs doctor gzip event\"));\n // No gzip here. That is the worst case: compression off, or a browser without\n // CompressionStream. The library gives a segment delivery.requestTimeoutMs, so the tool\n // waits for the default of that. A shorter wait would fail a slow link the library can use.\n const large = await poster(target, CONTENT_TYPE_JSON, LIBRARY_TIMEOUT_MS)(\n idOf(2),\n 0,\n segment(2, \"x\".repeat(LARGE_EVENT_CHARS)),\n );\n\n return [\n ...preflightResults(preflight, target),\n judge(\n \"test segment\",\n first,\n `The server accepted a test segment.${starNote(allowedOrigin(first) === \"*\", target)}`,\n statusProblem,\n originProblem,\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip segment.\", statusProblem),\n judge(\n \"large segment\",\n large,\n `The server accepted a segment of ${String(LARGE_EVENT_CHARS)} bytes without gzip.`,\n // The library drops a segment after a 413, so a low body limit loses every replay.\n (response) =>\n response.ok\n ? undefined\n : `The server returned ${String(response.status)} for a segment of ${String(LARGE_EVENT_CHARS)} bytes. The first segment of an upload has a full snapshot of the page. Raise the body limit of the server.`,\n ),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the segment again.\",\n statusProblem,\n ),\n ];\n}\n\n/** The options after the origin and the replay flag. */\ninterface Options {\n /** The headers of the --header options. */\n headers: Record<string, string>;\n /** True with `--credentials include`. */\n credentials: boolean;\n}\n\n/**\n * Parses the options. Each one is a flag and its value: a \"Name: value\" argument for a header,\n * or `include` for the credentials.\n * @param args The arguments after the origin.\n * @returns The options, or undefined if an option is malformed.\n */\nfunction parseOptions(args: readonly string[]): Options | undefined {\n const pairs: [string, string][] = [];\n let credentials = false;\n\n for (let index = 0; index < args.length; index += 2) {\n if (args[index] === CREDENTIALS_FLAG && args[index + 1] === CREDENTIALS_INCLUDE) {\n credentials = true;\n continue;\n }\n\n // A flag without a value leaves undefined here, which exec() treats as text with no colon.\n const match = args[index] === HEADER_FLAG ? HEADER_PATTERN.exec(args[index + 1]) : null;\n\n if (!match || RESERVED_HEADERS.includes(match[1].toLowerCase())) {\n return undefined;\n }\n\n pairs.push([match[1], match[2]]);\n }\n\n return { headers: Object.fromEntries(pairs), credentials };\n}\n\n/** True for an HTTP URL without a user name or password. Result lines print the URL. */\nfunction isHttpUrl(value: string): boolean {\n if (!/^https?:\\/\\//i.test(value) || !URL.canParse(value)) {\n return false;\n }\n\n const { username, password } = new URL(value);\n return username === \"\" && password === \"\";\n}\n\n/** Command line words that are safe to print. */\nconst SHOWN_WORDS = [\n \"doctor\",\n \"--origin\",\n REPLAY_FLAG,\n HEADER_FLAG,\n CREDENTIALS_FLAG,\n CREDENTIALS_INCLUDE,\n];\n\n/**\n * Turns an argument into something safe to print in the usage message. An argument can be a\n * token, a URL can carry one in its query or user info, and the output may land in a shared log.\n * @param arg Command line argument.\n * @returns The word itself, a URL without query or user info, or a placeholder.\n */\nfunction shownArgument(arg: string): string {\n if (SHOWN_WORDS.includes(arg)) {\n return arg;\n }\n\n if (/^https?:\\/\\//i.test(arg) && URL.canParse(arg)) {\n const { origin, pathname } = new URL(arg);\n return `${origin}${pathname === \"/\" && !arg.endsWith(\"/\") ? \"\" : pathname}`;\n }\n\n return HIDDEN;\n}\n\n/** Checks for an exact browser origin. A path or a trailing slash doesn't match. */\nfunction isOrigin(value: string): boolean {\n return URL.canParse(value) && new URL(value).origin === value;\n}\n\n/**\n * Runs the command line tool.\n * @param args Arguments after the program name.\n * @param print Writes one line of output.\n * @returns The exit code.\n */\nexport async function main(\n args: readonly string[],\n print: (line: string) => void,\n): Promise<number> {\n const [command, url, flag, origin, ...rest] = args;\n // The replay flag comes right after the origin, before any other option.\n const replay = rest[0] === REPLAY_FLAG;\n const options = parseOptions(replay ? rest.slice(1) : rest);\n\n if (\n command !== \"doctor\" ||\n flag !== \"--origin\" ||\n !isHttpUrl(url) ||\n !isOrigin(origin) ||\n !options\n ) {\n print(USAGE);\n print(`Received: ${JSON.stringify(args.map(shownArgument))}`);\n return EXIT_USAGE;\n }\n\n const { headers, credentials } = options;\n const results = await (replay ? runReplayDoctor : runDoctor)(url, origin, headers, credentials);\n\n for (const { rule, pass, detail } of results) {\n print(`${pass ? \"PASS\" : \"FAIL\"} ${rule}: ${detail}`);\n }\n\n return results.every(({ pass }) => pass) ? EXIT_PASS : EXIT_FAIL;\n}\n"],"mappings":"A,wLA4BA,IAAMmB,EAAqB,IAGrBC,EAAY,EAGZC,EAAY,EAGZC,EAAa,EAGbC,EACJ,6PAGIC,EAAc,WAGdC,EAAc,WAGdC,EAAmB,gBAG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AAG,CAClD,GAAM,CAAE,SAAQ,YAAa,IAAI,IAAIA,CAAG,EACxC,MAAO,GAAG1D,IAAS2D,IAAa,KAAO,CAACD,EAAI,SAAS,GAAG,EAAI,GAAKC,GACnE,CAEA,OAAO1G,CACT,CAGA,SAAS2G,GAAS,EAAwB,CACxC,OAAO,IAAI,SAASjF,CAAK,GAAK,IAAI,IAAIA,CAAK,CAAC,CAAC,SAAWA,CAC1D,CAQA,eAAsBkF,GACpB,EACA,EACiB,CACjB,GAAM,CAACC,EAAS1F,EAAK2F,EAAM/D,EAAQ,GAAGgE,GAAQb,EAExCc,EAASD,EAAK,KAAOtH,EACrBwH,EAAUlB,EAAaiB,EAASD,EAAK,MAAM,CAAC,EAAIA,CAAI,EAE1D,GACEF,IAAY,UACZC,IAAS,YACT,CAACV,EAAUjF,CAAG,GACd,CAACwF,GAAS5D,CAAM,GAChB,CAACkE,EAID,OAFAC,EAAM3H,CAAK,EACX2H,EAAM,aAAa,KAAK,UAAUhB,EAAK,IAAIM,EAAa,CAAC,GAAG,EACrDlH,EAGT,GAAM,CAAE,UAAS,eAAgB2H,EAC3BE,EAAU,MAAOH,EAAS3B,EAAkBX,EAAA,CAAWvD,EAAK4B,EAAQqE,EAAStE,CAAW,EAE9F,IAAK,GAAM,CAAE,OAAM,OAAM,YAAYqE,EACnCD,EAAM,GAAGG,EAAO,OAAS,OAAO,GAAGC,EAAK,IAAIC,GAAQ,EAGtD,OAAOJ,EAAQ,OAAO,CAAE,UAAWE,CAAI,EAAIjI,EAAYC,CACzD,C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The result of one ingest contract rule. */
|
|
2
|
+
export interface DoctorResult {
|
|
3
|
+
/** Rule name. */
|
|
4
|
+
rule: string;
|
|
5
|
+
/** True when the server meets the rule. */
|
|
6
|
+
pass: boolean;
|
|
7
|
+
/** Why the rule passed or failed. */
|
|
8
|
+
detail: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Runs each rule's requests one at a time. Two requests with the same batch id must not overlap.
|
|
12
|
+
* @param url Ingest URL.
|
|
13
|
+
* @param origin The app's origin.
|
|
14
|
+
* @param custom The app's headers for each batch, e.g. an Authorization header.
|
|
15
|
+
* @param credentials True when the app sets `credentials: "include"`. A * in a CORS header then
|
|
16
|
+
* fails, and the preflight must allow credentials.
|
|
17
|
+
* @returns One result per rule.
|
|
18
|
+
*/
|
|
19
|
+
export declare function runDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>, credentials?: boolean): Promise<DoctorResult[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks a replay endpoint the way runDoctor() checks an ingest server. A segment has its own
|
|
22
|
+
* body and its own batch id form, and its first one can be several megabytes.
|
|
23
|
+
* @param url Replay endpoint URL, the value of replay.endpoint.
|
|
24
|
+
* @param origin The app's origin.
|
|
25
|
+
* @param custom The app's replay.headers, e.g. an Authorization header.
|
|
26
|
+
* @param credentials True when the app sets `credentials: "include"`. See runDoctor().
|
|
27
|
+
* @returns One result per rule.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runReplayDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>, credentials?: boolean): Promise<DoctorResult[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Runs the command line tool.
|
|
32
|
+
* @param args Arguments after the program name.
|
|
33
|
+
* @param print Writes one line of output.
|
|
34
|
+
* @returns The exit code.
|
|
35
|
+
*/
|
|
36
|
+
export declare function main(args: readonly string[], print: (line: string) => void): Promise<number>;
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The result of one ingest contract rule. */
|
|
2
2
|
export interface DoctorResult {
|
|
3
3
|
/** Rule name. */
|
|
4
4
|
rule: string;
|
|
5
5
|
/** True when the server meets the rule. */
|
|
6
6
|
pass: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/** Why the rule passed or failed. */
|
|
8
8
|
detail: string;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Runs each rule's requests one at a time. Two requests with the same batch id must not overlap.
|
|
12
12
|
* @param url Ingest URL.
|
|
13
|
-
* @param origin
|
|
14
|
-
* @
|
|
13
|
+
* @param origin The app's origin.
|
|
14
|
+
* @param custom The app's headers for each batch, e.g. an Authorization header.
|
|
15
|
+
* @param credentials True when the app sets `credentials: "include"`. A * in a CORS header then
|
|
16
|
+
* fails, and the preflight must allow credentials.
|
|
17
|
+
* @returns One result per rule.
|
|
15
18
|
*/
|
|
16
|
-
export declare function runDoctor(url: string, origin: string): Promise<DoctorResult[]>;
|
|
19
|
+
export declare function runDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>, credentials?: boolean): Promise<DoctorResult[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks a replay endpoint the way runDoctor() checks an ingest server. A segment has its own
|
|
22
|
+
* body and its own batch id form, and its first one can be several megabytes.
|
|
23
|
+
* @param url Replay endpoint URL, the value of replay.endpoint.
|
|
24
|
+
* @param origin The app's origin.
|
|
25
|
+
* @param custom The app's replay.headers, e.g. an Authorization header.
|
|
26
|
+
* @param credentials True when the app sets `credentials: "include"`. See runDoctor().
|
|
27
|
+
* @returns One result per rule.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runReplayDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>, credentials?: boolean): Promise<DoctorResult[]>;
|
|
17
30
|
/**
|
|
18
31
|
* Runs the command line tool.
|
|
19
32
|
* @param args Arguments after the program name.
|