@blockcast/mmt-container 0.1.0-main.149f78a4adae
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/README.md +432 -0
- package/dist/.build-stamp +0 -0
- package/dist/__tests__/test-utils.d.ts +71 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/align.d.ts +148 -0
- package/dist/align.d.ts.map +1 -0
- package/dist/align.js +88 -0
- package/dist/align.js.map +7 -0
- package/dist/audio-init-parser.d.ts +66 -0
- package/dist/audio-init-parser.d.ts.map +1 -0
- package/dist/audio-init-parser.js +118 -0
- package/dist/audio-init-parser.js.map +7 -0
- package/dist/audio-ring-buffer.d.ts +50 -0
- package/dist/audio-ring-buffer.d.ts.map +1 -0
- package/dist/audio-ring-buffer.js +93 -0
- package/dist/audio-ring-buffer.js.map +7 -0
- package/dist/authored-timing.d.ts +32 -0
- package/dist/authored-timing.d.ts.map +1 -0
- package/dist/authored-timing.js +32 -0
- package/dist/authored-timing.js.map +7 -0
- package/dist/browser-runtime.js +17109 -0
- package/dist/browser-runtime.js.map +7 -0
- package/dist/carp-catalog.d.ts +318 -0
- package/dist/carp-catalog.d.ts.map +1 -0
- package/dist/carp-catalog.js +549 -0
- package/dist/carp-catalog.js.map +7 -0
- package/dist/catalog-fec-params.d.ts +82 -0
- package/dist/catalog-fec-params.d.ts.map +1 -0
- package/dist/catalog-fec-params.js +66 -0
- package/dist/catalog-fec-params.js.map +7 -0
- package/dist/catalog-network-source.d.ts +19 -0
- package/dist/catalog-network-source.d.ts.map +1 -0
- package/dist/catalog-network-source.js +22 -0
- package/dist/catalog-network-source.js.map +7 -0
- package/dist/catalog-validator.d.ts +18 -0
- package/dist/catalog-validator.d.ts.map +1 -0
- package/dist/catalog-validator.js +7747 -0
- package/dist/catalog-validator.js.map +7 -0
- package/dist/cmaf-block-assembler.d.ts +168 -0
- package/dist/cmaf-block-assembler.d.ts.map +1 -0
- package/dist/cmaf-block-assembler.js +1755 -0
- package/dist/cmaf-block-assembler.js.map +7 -0
- package/dist/cmaf-group-batcher.d.ts +38 -0
- package/dist/cmaf-group-batcher.d.ts.map +1 -0
- package/dist/cmaf-group-batcher.js +195 -0
- package/dist/cmaf-group-batcher.js.map +7 -0
- package/dist/cmcd-producer.d.ts +104 -0
- package/dist/cmcd-producer.d.ts.map +1 -0
- package/dist/cmcd-producer.js +207 -0
- package/dist/cmcd-producer.js.map +7 -0
- package/dist/codec-utils.d.ts +235 -0
- package/dist/codec-utils.d.ts.map +1 -0
- package/dist/codec-utils.js +1225 -0
- package/dist/codec-utils.js.map +7 -0
- package/dist/fec-codec.d.ts +32 -0
- package/dist/fec-codec.d.ts.map +1 -0
- package/dist/fec-codec.js +47 -0
- package/dist/fec-codec.js.map +7 -0
- package/dist/fec-manager.d.ts +266 -0
- package/dist/fec-manager.d.ts.map +1 -0
- package/dist/fec-manager.js +1447 -0
- package/dist/fec-manager.js.map +7 -0
- package/dist/fec-starvation-detector.d.ts +59 -0
- package/dist/fec-starvation-detector.d.ts.map +1 -0
- package/dist/fec-starvation-detector.js +75 -0
- package/dist/fec-starvation-detector.js.map +7 -0
- package/dist/fec-worker-setup.d.ts +76 -0
- package/dist/fec-worker-setup.d.ts.map +1 -0
- package/dist/fec-worker-setup.js +603 -0
- package/dist/fec-worker-setup.js.map +7 -0
- package/dist/fmp4-completion.d.ts +30 -0
- package/dist/fmp4-completion.d.ts.map +1 -0
- package/dist/fmp4-completion.js +21 -0
- package/dist/fmp4-completion.js.map +7 -0
- package/dist/fmp4-reader.d.ts +37 -0
- package/dist/fmp4-reader.d.ts.map +1 -0
- package/dist/fmp4-reader.js +100 -0
- package/dist/fmp4-reader.js.map +7 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +330 -0
- package/dist/index.js.map +7 -0
- package/dist/iso-bmff-timing.d.ts +47 -0
- package/dist/iso-bmff-timing.d.ts.map +1 -0
- package/dist/iso-bmff-timing.js +526 -0
- package/dist/iso-bmff-timing.js.map +7 -0
- package/dist/loc.d.ts +68 -0
- package/dist/loc.d.ts.map +1 -0
- package/dist/loc.js +143 -0
- package/dist/loc.js.map +7 -0
- package/dist/manifest-auth-plan.d.ts +30 -0
- package/dist/manifest-auth-plan.d.ts.map +1 -0
- package/dist/manifest-auth-plan.js +1267 -0
- package/dist/manifest-auth-plan.js.map +7 -0
- package/dist/media-router.d.ts +338 -0
- package/dist/media-router.d.ts.map +1 -0
- package/dist/media-router.js +802 -0
- package/dist/media-router.js.map +7 -0
- package/dist/mfu-reassembler.d.ts +264 -0
- package/dist/mfu-reassembler.d.ts.map +1 -0
- package/dist/mfu-reassembler.js +2668 -0
- package/dist/mfu-reassembler.js.map +7 -0
- package/dist/mfu-reassembly-policy.d.ts +24 -0
- package/dist/mfu-reassembly-policy.d.ts.map +1 -0
- package/dist/mfu-reassembly-policy.js +99 -0
- package/dist/mfu-reassembly-policy.js.map +7 -0
- package/dist/mmtp-container-parser.d.ts +304 -0
- package/dist/mmtp-container-parser.d.ts.map +1 -0
- package/dist/mmtp-container-parser.js +5378 -0
- package/dist/mmtp-container-parser.js.map +7 -0
- package/dist/mmtp-container-parser.no-modules.js +7853 -0
- package/dist/mmtp-container-parser.no-modules.js.map +7 -0
- package/dist/mmtp-decode-pipeline.d.ts +96 -0
- package/dist/mmtp-decode-pipeline.d.ts.map +1 -0
- package/dist/mmtp-decode-pipeline.js +5589 -0
- package/dist/mmtp-decode-pipeline.js.map +7 -0
- package/dist/mmtp-router.d.ts +383 -0
- package/dist/mmtp-router.d.ts.map +1 -0
- package/dist/mmtp-router.js +8384 -0
- package/dist/mmtp-router.js.map +7 -0
- package/dist/mmtp-to-cmaf.d.ts +166 -0
- package/dist/mmtp-to-cmaf.d.ts.map +1 -0
- package/dist/mmtp-to-cmaf.js +781 -0
- package/dist/mmtp-to-cmaf.js.map +7 -0
- package/dist/multicast-auth-catalog.d.ts +115 -0
- package/dist/multicast-auth-catalog.d.ts.map +1 -0
- package/dist/multicast-auth-catalog.js +202 -0
- package/dist/multicast-auth-catalog.js.map +7 -0
- package/dist/multicast-input.d.ts +107 -0
- package/dist/multicast-input.d.ts.map +1 -0
- package/dist/multicast-input.js +256 -0
- package/dist/multicast-input.js.map +7 -0
- package/dist/multicast-manager.d.ts +330 -0
- package/dist/multicast-manager.d.ts.map +1 -0
- package/dist/multicast-manager.js +11032 -0
- package/dist/multicast-manager.js.map +7 -0
- package/dist/multicast-transport.d.ts +62 -0
- package/dist/multicast-transport.d.ts.map +1 -0
- package/dist/multicast-transport.js +338 -0
- package/dist/multicast-transport.js.map +7 -0
- package/dist/multicast-unwrap.d.ts +57 -0
- package/dist/multicast-unwrap.d.ts.map +1 -0
- package/dist/multicast-unwrap.js +384 -0
- package/dist/multicast-unwrap.js.map +7 -0
- package/dist/no-modules.d.ts +9 -0
- package/dist/no-modules.d.ts.map +1 -0
- package/dist/no-modules.js +7819 -0
- package/dist/no-modules.js.map +7 -0
- package/dist/phase14-catalog-override.d.ts +126 -0
- package/dist/phase14-catalog-override.d.ts.map +1 -0
- package/dist/phase14-catalog-override.js +155 -0
- package/dist/phase14-catalog-override.js.map +7 -0
- package/dist/repair-fetch.d.ts +58 -0
- package/dist/repair-fetch.d.ts.map +1 -0
- package/dist/repair-fetch.js +117 -0
- package/dist/repair-fetch.js.map +7 -0
- package/dist/sample-combiner.d.ts +182 -0
- package/dist/sample-combiner.d.ts.map +1 -0
- package/dist/sample-combiner.js +571 -0
- package/dist/sample-combiner.js.map +7 -0
- package/dist/signaling.d.ts +29 -0
- package/dist/signaling.d.ts.map +1 -0
- package/dist/signaling.js +232 -0
- package/dist/signaling.js.map +7 -0
- package/dist/source-auth.d.ts +2 -0
- package/dist/source-auth.d.ts.map +1 -0
- package/dist/source-auth.js +1220 -0
- package/dist/source-auth.js.map +7 -0
- package/dist/switching-set-alignment.d.ts +61 -0
- package/dist/switching-set-alignment.d.ts.map +1 -0
- package/dist/switching-set-alignment.js +85 -0
- package/dist/switching-set-alignment.js.map +7 -0
- package/dist/timestamp-codec.d.ts +34 -0
- package/dist/timestamp-codec.d.ts.map +1 -0
- package/dist/timestamp-codec.js +456 -0
- package/dist/timestamp-codec.js.map +7 -0
- package/dist/track-pipeline-setup.d.ts +72 -0
- package/dist/track-pipeline-setup.d.ts.map +1 -0
- package/dist/track-pipeline-setup.js +306 -0
- package/dist/track-pipeline-setup.js.map +7 -0
- package/dist/track-pipeline.d.ts +121 -0
- package/dist/track-pipeline.d.ts.map +1 -0
- package/dist/track-pipeline.js +229 -0
- package/dist/track-pipeline.js.map +7 -0
- package/dist/track-session.d.ts +269 -0
- package/dist/track-session.d.ts.map +1 -0
- package/dist/track-session.js +597 -0
- package/dist/track-session.js.map +7 -0
- package/dist/transport-pool.d.ts +69 -0
- package/dist/transport-pool.d.ts.map +1 -0
- package/dist/transport-pool.js +88 -0
- package/dist/transport-pool.js.map +7 -0
- package/dist/wasm-mfu-reassembler.d.ts +81 -0
- package/dist/wasm-mfu-reassembler.d.ts.map +1 -0
- package/dist/wasm-mfu-reassembler.js +1915 -0
- package/dist/wasm-mfu-reassembler.js.map +7 -0
- package/dist/wasm-mmtp-container-parser.d.ts +10 -0
- package/dist/wasm-mmtp-container-parser.d.ts.map +1 -0
- package/dist/wasm-mmtp-container-parser.js +5635 -0
- package/dist/wasm-mmtp-container-parser.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/README.md +213 -0
- package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +80 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +270 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +252 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +11 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +14 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +565 -0
- package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts +10 -0
- package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/index.js +8 -0
- package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +20 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +349 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +7 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +104 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +181 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +179 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +47 -0
- package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +9 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +1 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.js +13 -0
- package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +1 -0
- package/node_modules/@blockcast/fec-worker/package.json +59 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +309 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +268 -0
- package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +1048 -0
- package/node_modules/@blockcast/fec-worker/src/index.ts +32 -0
- package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +558 -0
- package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +222 -0
- package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +194 -0
- package/node_modules/@blockcast/fec-worker/src/transfer.ts +12 -0
- package/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
- package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
- package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
- package/node_modules/@blockcast/mmt-base/README.md +120 -0
- package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
- package/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
- package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
- package/node_modules/@blockcast/mmt-base/package.json +49 -0
- package/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
- package/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
- package/node_modules/@blockcast/mmt-fec/README.md +270 -0
- package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +80 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +294 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +72 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +192 -0
- package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +46 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +96 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +33 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +57 -0
- package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +185 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +273 -0
- package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +22 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.js +22 -0
- package/node_modules/@blockcast/mmt-fec/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +20 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +28 -0
- package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +174 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.js +256 -0
- package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +41 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +81 -0
- package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +181 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +57 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +115 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +50 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +136 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +120 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +2 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +2 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +275 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +644 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +49 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +1 -0
- package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +898 -0
- package/node_modules/@blockcast/mmt-fec/package.json +79 -0
- package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +369 -0
- package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +277 -0
- package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +127 -0
- package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +68 -0
- package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +332 -0
- package/node_modules/@blockcast/mmt-fec/src/index.ts +77 -0
- package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +34 -0
- package/node_modules/@blockcast/mmt-fec/src/oti.ts +319 -0
- package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +101 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +28 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +128 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +4 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +4 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +37 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +179 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +90 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +462 -0
- package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +1 -0
- package/node_modules/@blockcast/mmt-manifest-verify/package.json +45 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +171 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +3 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +230 -0
- package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +636 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +521 -0
- package/node_modules/@noble/hashes/_assert.d.ts +17 -0
- package/node_modules/@noble/hashes/_assert.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_assert.js +18 -0
- package/node_modules/@noble/hashes/_assert.js.map +1 -0
- package/node_modules/@noble/hashes/_blake.d.ts +14 -0
- package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_blake.js +50 -0
- package/node_modules/@noble/hashes/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/_md.d.ts +51 -0
- package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_md.js +162 -0
- package/node_modules/@noble/hashes/_md.js.map +1 -0
- package/node_modules/@noble/hashes/_u64.d.ts +55 -0
- package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_u64.js +90 -0
- package/node_modules/@noble/hashes/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/argon2.d.ts +32 -0
- package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/argon2.js +401 -0
- package/node_modules/@noble/hashes/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/blake1.d.ts +106 -0
- package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake1.js +459 -0
- package/node_modules/@noble/hashes/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/blake2.d.ts +116 -0
- package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2.js +420 -0
- package/node_modules/@noble/hashes/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/blake2b.d.ts +11 -0
- package/node_modules/@noble/hashes/blake2b.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2b.js +14 -0
- package/node_modules/@noble/hashes/blake2b.js.map +1 -0
- package/node_modules/@noble/hashes/blake2s.d.ts +20 -0
- package/node_modules/@noble/hashes/blake2s.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2s.js +24 -0
- package/node_modules/@noble/hashes/blake2s.js.map +1 -0
- package/node_modules/@noble/hashes/blake3.d.ts +54 -0
- package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake3.js +255 -0
- package/node_modules/@noble/hashes/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/crypto.d.ts +2 -0
- package/node_modules/@noble/hashes/crypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/crypto.js +5 -0
- package/node_modules/@noble/hashes/crypto.js.map +1 -0
- package/node_modules/@noble/hashes/cryptoNode.d.ts +2 -0
- package/node_modules/@noble/hashes/cryptoNode.d.ts.map +1 -0
- package/node_modules/@noble/hashes/cryptoNode.js +18 -0
- package/node_modules/@noble/hashes/cryptoNode.js.map +1 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +47 -0
- package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/eskdf.js +166 -0
- package/node_modules/@noble/hashes/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_assert.d.ts +17 -0
- package/node_modules/@noble/hashes/esm/_assert.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_assert.js +15 -0
- package/node_modules/@noble/hashes/esm/_assert.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_blake.d.ts +14 -0
- package/node_modules/@noble/hashes/esm/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_blake.js +45 -0
- package/node_modules/@noble/hashes/esm/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_md.d.ts +51 -0
- package/node_modules/@noble/hashes/esm/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_md.js +155 -0
- package/node_modules/@noble/hashes/esm/_md.js.map +1 -0
- package/node_modules/@noble/hashes/esm/_u64.d.ts +55 -0
- package/node_modules/@noble/hashes/esm/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/_u64.js +67 -0
- package/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/esm/argon2.d.ts +32 -0
- package/node_modules/@noble/hashes/esm/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/argon2.js +392 -0
- package/node_modules/@noble/hashes/esm/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake1.d.ts +106 -0
- package/node_modules/@noble/hashes/esm/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake1.js +452 -0
- package/node_modules/@noble/hashes/esm/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2.d.ts +116 -0
- package/node_modules/@noble/hashes/esm/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2.js +413 -0
- package/node_modules/@noble/hashes/esm/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2b.d.ts +11 -0
- package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2b.js +11 -0
- package/node_modules/@noble/hashes/esm/blake2b.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2s.d.ts +20 -0
- package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake2s.js +21 -0
- package/node_modules/@noble/hashes/esm/blake2s.js.map +1 -0
- package/node_modules/@noble/hashes/esm/blake3.d.ts +54 -0
- package/node_modules/@noble/hashes/esm/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/blake3.js +251 -0
- package/node_modules/@noble/hashes/esm/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/esm/crypto.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/crypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/crypto.js +2 -0
- package/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.js +15 -0
- package/node_modules/@noble/hashes/esm/cryptoNode.js.map +1 -0
- package/node_modules/@noble/hashes/esm/eskdf.d.ts +47 -0
- package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/eskdf.js +160 -0
- package/node_modules/@noble/hashes/esm/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/hkdf.d.ts +36 -0
- package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/hkdf.js +82 -0
- package/node_modules/@noble/hashes/esm/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/esm/hmac.d.ts +35 -0
- package/node_modules/@noble/hashes/esm/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/hmac.js +86 -0
- package/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/esm/index.d.ts +2 -0
- package/node_modules/@noble/hashes/esm/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/index.js +33 -0
- package/node_modules/@noble/hashes/esm/index.js.map +1 -0
- package/node_modules/@noble/hashes/esm/legacy.d.ts +71 -0
- package/node_modules/@noble/hashes/esm/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/legacy.js +281 -0
- package/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/esm/package.json +10 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +23 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.js +97 -0
- package/node_modules/@noble/hashes/esm/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/ripemd160.d.ts +13 -0
- package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/ripemd160.js +13 -0
- package/node_modules/@noble/hashes/esm/ripemd160.js.map +1 -0
- package/node_modules/@noble/hashes/esm/scrypt.d.ts +34 -0
- package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/scrypt.js +228 -0
- package/node_modules/@noble/hashes/esm/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha1.d.ts +11 -0
- package/node_modules/@noble/hashes/esm/sha1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha1.js +11 -0
- package/node_modules/@noble/hashes/esm/sha1.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha2.d.ts +159 -0
- package/node_modules/@noble/hashes/esm/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha2.js +375 -0
- package/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha256.d.ts +20 -0
- package/node_modules/@noble/hashes/esm/sha256.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha256.js +20 -0
- package/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +142 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.js +393 -0
- package/node_modules/@noble/hashes/esm/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3.d.ts +53 -0
- package/node_modules/@noble/hashes/esm/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha3.js +234 -0
- package/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/esm/sha512.d.ts +26 -0
- package/node_modules/@noble/hashes/esm/sha512.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/sha512.js +26 -0
- package/node_modules/@noble/hashes/esm/sha512.js.map +1 -0
- package/node_modules/@noble/hashes/esm/utils.d.ts +161 -0
- package/node_modules/@noble/hashes/esm/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/esm/utils.js +281 -0
- package/node_modules/@noble/hashes/esm/utils.js.map +1 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
- package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hkdf.js +88 -0
- package/node_modules/@noble/hashes/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/hmac.d.ts +35 -0
- package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hmac.js +91 -0
- package/node_modules/@noble/hashes/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/index.js +33 -0
- package/node_modules/@noble/hashes/index.js.map +1 -0
- package/node_modules/@noble/hashes/legacy.d.ts +71 -0
- package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/legacy.js +287 -0
- package/node_modules/@noble/hashes/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/package.json +266 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +23 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/pbkdf2.js +101 -0
- package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/ripemd160.d.ts +13 -0
- package/node_modules/@noble/hashes/ripemd160.d.ts.map +1 -0
- package/node_modules/@noble/hashes/ripemd160.js +16 -0
- package/node_modules/@noble/hashes/ripemd160.js.map +1 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +34 -0
- package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/scrypt.js +232 -0
- package/node_modules/@noble/hashes/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/sha1.d.ts +11 -0
- package/node_modules/@noble/hashes/sha1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha1.js +14 -0
- package/node_modules/@noble/hashes/sha1.js.map +1 -0
- package/node_modules/@noble/hashes/sha2.d.ts +159 -0
- package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha2.js +384 -0
- package/node_modules/@noble/hashes/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/sha256.d.ts +20 -0
- package/node_modules/@noble/hashes/sha256.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha256.js +23 -0
- package/node_modules/@noble/hashes/sha256.js.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +142 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.js +402 -0
- package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/sha3.d.ts +53 -0
- package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3.js +239 -0
- package/node_modules/@noble/hashes/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/sha512.d.ts +26 -0
- package/node_modules/@noble/hashes/sha512.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha512.js +29 -0
- package/node_modules/@noble/hashes/sha512.js.map +1 -0
- package/node_modules/@noble/hashes/src/_assert.ts +22 -0
- package/node_modules/@noble/hashes/src/_blake.ts +50 -0
- package/node_modules/@noble/hashes/src/_md.ts +176 -0
- package/node_modules/@noble/hashes/src/_u64.ts +91 -0
- package/node_modules/@noble/hashes/src/argon2.ts +497 -0
- package/node_modules/@noble/hashes/src/blake1.ts +534 -0
- package/node_modules/@noble/hashes/src/blake2.ts +486 -0
- package/node_modules/@noble/hashes/src/blake2b.ts +10 -0
- package/node_modules/@noble/hashes/src/blake2s.ts +20 -0
- package/node_modules/@noble/hashes/src/blake3.ts +272 -0
- package/node_modules/@noble/hashes/src/crypto.ts +9 -0
- package/node_modules/@noble/hashes/src/cryptoNode.ts +15 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +187 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +88 -0
- package/node_modules/@noble/hashes/src/hmac.ts +94 -0
- package/node_modules/@noble/hashes/src/index.ts +31 -0
- package/node_modules/@noble/hashes/src/legacy.ts +293 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +122 -0
- package/node_modules/@noble/hashes/src/ripemd160.ts +12 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +257 -0
- package/node_modules/@noble/hashes/src/sha1.ts +10 -0
- package/node_modules/@noble/hashes/src/sha2.ts +402 -0
- package/node_modules/@noble/hashes/src/sha256.ts +24 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +499 -0
- package/node_modules/@noble/hashes/src/sha3.ts +258 -0
- package/node_modules/@noble/hashes/src/sha512.ts +34 -0
- package/node_modules/@noble/hashes/src/utils.ts +395 -0
- package/node_modules/@noble/hashes/utils.d.ts +161 -0
- package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/utils.js +313 -0
- package/node_modules/@noble/hashes/utils.js.map +1 -0
- package/package.json +203 -0
- package/schemas/catalog.schema.json +283 -0
- package/src/align.ts +235 -0
- package/src/audio-init-parser.ts +189 -0
- package/src/audio-ring-buffer.ts +120 -0
- package/src/authored-timing.ts +63 -0
- package/src/carp-catalog.ts +776 -0
- package/src/catalog-fec-params.ts +167 -0
- package/src/catalog-network-source.ts +49 -0
- package/src/catalog-validator.ts +34 -0
- package/src/cmaf-block-assembler.ts +1058 -0
- package/src/cmaf-group-batcher.ts +104 -0
- package/src/cmcd-producer.ts +329 -0
- package/src/codec-utils.ts +1539 -0
- package/src/fec-codec.ts +61 -0
- package/src/fec-manager.ts +1939 -0
- package/src/fec-starvation-detector.ts +128 -0
- package/src/fec-worker-setup.ts +177 -0
- package/src/fmp4-completion.ts +47 -0
- package/src/fmp4-reader.ts +112 -0
- package/src/index.ts +443 -0
- package/src/iso-bmff-timing.ts +688 -0
- package/src/loc.ts +181 -0
- package/src/manifest-auth-plan.ts +107 -0
- package/src/media-router.ts +1185 -0
- package/src/mfu-reassembler.ts +2842 -0
- package/src/mfu-reassembly-policy.ts +134 -0
- package/src/mmtp-container-parser.ts +1498 -0
- package/src/mmtp-decode-pipeline.ts +315 -0
- package/src/mmtp-router.ts +3027 -0
- package/src/mmtp-to-cmaf.ts +956 -0
- package/src/multicast-auth-catalog.ts +340 -0
- package/src/multicast-input.ts +439 -0
- package/src/multicast-manager.ts +1503 -0
- package/src/multicast-transport.ts +320 -0
- package/src/multicast-unwrap.ts +132 -0
- package/src/no-modules.ts +20 -0
- package/src/phase14-catalog-override.ts +336 -0
- package/src/repair-fetch.ts +217 -0
- package/src/sample-combiner.ts +846 -0
- package/src/signaling.ts +78 -0
- package/src/source-auth.ts +1 -0
- package/src/switching-set-alignment.ts +109 -0
- package/src/timestamp-codec.ts +265 -0
- package/src/track-pipeline-setup.ts +189 -0
- package/src/track-pipeline.ts +332 -0
- package/src/track-session.ts +778 -0
- package/src/transport-pool.ts +128 -0
- package/src/wasm-mfu-reassembler.ts +372 -0
- package/src/wasm-mmtp-container-parser.ts +23 -0
- package/test-vectors/align.json +199 -0
- package/test-vectors/catalog/README.md +25 -0
- package/test-vectors/catalog/negative/legacy-selection-params.json +15 -0
- package/test-vectors/catalog/negative/missing-mmtp-fields.json +12 -0
- package/test-vectors/catalog/negative/multicast-auth-padded-key.json +37 -0
- package/test-vectors/catalog/negative/multicast-auth-reused-track-format.json +53 -0
- package/test-vectors/catalog/negative/multicast-auth-trailing-pad-bits.json +37 -0
- package/test-vectors/catalog/negative/multicast-endpoint-missing-protocol-and-source.json +24 -0
- package/test-vectors/catalog/negative/network-source-object.json +25 -0
- package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +26 -0
- package/test-vectors/catalog/negative/repair-track-legacy-shape.json +18 -0
- package/test-vectors/catalog/negative/track-role-empty.json +16 -0
- package/test-vectors/catalog/negative/track-role-non-string.json +16 -0
- package/test-vectors/catalog/positive/fec-multicast.json +51 -0
- package/test-vectors/catalog/positive/flat-av.json +30 -0
- package/test-vectors/catalog/positive/multicast-auth-rotation.json +55 -0
- package/test-vectors/catalog/positive/ticks-and-mixed-timescales.json +39 -0
- package/test-vectors/catalog/positive/track-role.json +49 -0
- package/test-vectors/catalog/releases/moqcast-native-v16-v1/catalog.json +65 -0
- package/test-vectors/catalog/releases/moqcast-native-v16-v1.archive.sha256 +1 -0
- package/test-vectors/catalog-multicast-auth-v1.json +26 -0
- package/test-vectors/catalog-validation.json +148 -0
- package/test-vectors/catalog-validator-public-api.mjs +25 -0
- package/test-vectors/generate-source-auth-fixture.mjs +114 -0
- package/test-vectors/source-auth-v1.json +61 -0
- package/test-vectors/subsample-placement-v1.json +230 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA3 (keccak) hash function, based on a new "Sponge function" design.
|
|
3
|
+
* Different from older hashes, the internal state is bigger than output size.
|
|
4
|
+
*
|
|
5
|
+
* Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
|
|
6
|
+
* [Website](https://keccak.team/keccak.html),
|
|
7
|
+
* [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
|
|
8
|
+
*
|
|
9
|
+
* Check out `sha3-addons` module for cSHAKE, k12, and others.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.ts';
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
import {
|
|
15
|
+
abytes, aexists, anumber, aoutput,
|
|
16
|
+
clean, createHasher, createXOFer, Hash,
|
|
17
|
+
swap32IfBE,
|
|
18
|
+
toBytes, u32,
|
|
19
|
+
type CHash, type CHashXO, type HashXOF, type Input
|
|
20
|
+
} from './utils.ts';
|
|
21
|
+
|
|
22
|
+
// No __PURE__ annotations in sha3 header:
|
|
23
|
+
// EVERYTHING is in fact used on every export.
|
|
24
|
+
// Various per round constants calculations
|
|
25
|
+
const _0n = BigInt(0);
|
|
26
|
+
const _1n = BigInt(1);
|
|
27
|
+
const _2n = BigInt(2);
|
|
28
|
+
const _7n = BigInt(7);
|
|
29
|
+
const _256n = BigInt(256);
|
|
30
|
+
const _0x71n = BigInt(0x71);
|
|
31
|
+
const SHA3_PI: number[] = [];
|
|
32
|
+
const SHA3_ROTL: number[] = [];
|
|
33
|
+
const _SHA3_IOTA: bigint[] = [];
|
|
34
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
35
|
+
// Pi
|
|
36
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
37
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
38
|
+
// Rotational
|
|
39
|
+
SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
|
|
40
|
+
// Iota
|
|
41
|
+
let t = _0n;
|
|
42
|
+
for (let j = 0; j < 7; j++) {
|
|
43
|
+
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
|
44
|
+
if (R & _2n) t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
|
|
45
|
+
}
|
|
46
|
+
_SHA3_IOTA.push(t);
|
|
47
|
+
}
|
|
48
|
+
const IOTAS = split(_SHA3_IOTA, true);
|
|
49
|
+
const SHA3_IOTA_H = IOTAS[0];
|
|
50
|
+
const SHA3_IOTA_L = IOTAS[1];
|
|
51
|
+
|
|
52
|
+
// Left rotation (without 0, 32, 64)
|
|
53
|
+
const rotlH = (h: number, l: number, s: number) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
|
|
54
|
+
const rotlL = (h: number, l: number, s: number) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
|
|
55
|
+
|
|
56
|
+
/** `keccakf1600` internal function, additionally allows to adjust round count. */
|
|
57
|
+
export function keccakP(s: Uint32Array, rounds: number = 24): void {
|
|
58
|
+
const B = new Uint32Array(5 * 2);
|
|
59
|
+
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
|
|
60
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
61
|
+
// Theta θ
|
|
62
|
+
for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
63
|
+
for (let x = 0; x < 10; x += 2) {
|
|
64
|
+
const idx1 = (x + 8) % 10;
|
|
65
|
+
const idx0 = (x + 2) % 10;
|
|
66
|
+
const B0 = B[idx0];
|
|
67
|
+
const B1 = B[idx0 + 1];
|
|
68
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
69
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
70
|
+
for (let y = 0; y < 50; y += 10) {
|
|
71
|
+
s[x + y] ^= Th;
|
|
72
|
+
s[x + y + 1] ^= Tl;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Rho (ρ) and Pi (π)
|
|
76
|
+
let curH = s[2];
|
|
77
|
+
let curL = s[3];
|
|
78
|
+
for (let t = 0; t < 24; t++) {
|
|
79
|
+
const shift = SHA3_ROTL[t];
|
|
80
|
+
const Th = rotlH(curH, curL, shift);
|
|
81
|
+
const Tl = rotlL(curH, curL, shift);
|
|
82
|
+
const PI = SHA3_PI[t];
|
|
83
|
+
curH = s[PI];
|
|
84
|
+
curL = s[PI + 1];
|
|
85
|
+
s[PI] = Th;
|
|
86
|
+
s[PI + 1] = Tl;
|
|
87
|
+
}
|
|
88
|
+
// Chi (χ)
|
|
89
|
+
for (let y = 0; y < 50; y += 10) {
|
|
90
|
+
for (let x = 0; x < 10; x++) B[x] = s[y + x];
|
|
91
|
+
for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
92
|
+
}
|
|
93
|
+
// Iota (ι)
|
|
94
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
95
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
96
|
+
}
|
|
97
|
+
clean(B);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Keccak sponge function. */
|
|
101
|
+
export class Keccak extends Hash<Keccak> implements HashXOF<Keccak> {
|
|
102
|
+
protected state: Uint8Array;
|
|
103
|
+
protected pos = 0;
|
|
104
|
+
protected posOut = 0;
|
|
105
|
+
protected finished = false;
|
|
106
|
+
protected state32: Uint32Array;
|
|
107
|
+
protected destroyed = false;
|
|
108
|
+
|
|
109
|
+
public blockLen: number;
|
|
110
|
+
public suffix: number;
|
|
111
|
+
public outputLen: number;
|
|
112
|
+
protected enableXOF = false;
|
|
113
|
+
protected rounds: number;
|
|
114
|
+
|
|
115
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
116
|
+
constructor(
|
|
117
|
+
blockLen: number,
|
|
118
|
+
suffix: number,
|
|
119
|
+
outputLen: number,
|
|
120
|
+
enableXOF = false,
|
|
121
|
+
rounds: number = 24
|
|
122
|
+
) {
|
|
123
|
+
super();
|
|
124
|
+
this.blockLen = blockLen;
|
|
125
|
+
this.suffix = suffix;
|
|
126
|
+
this.outputLen = outputLen;
|
|
127
|
+
this.enableXOF = enableXOF;
|
|
128
|
+
this.rounds = rounds;
|
|
129
|
+
// Can be passed from user as dkLen
|
|
130
|
+
anumber(outputLen);
|
|
131
|
+
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
132
|
+
// 0 < blockLen < 200
|
|
133
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
134
|
+
throw new Error('only keccak-f1600 function is supported');
|
|
135
|
+
this.state = new Uint8Array(200);
|
|
136
|
+
this.state32 = u32(this.state);
|
|
137
|
+
}
|
|
138
|
+
clone(): Keccak {
|
|
139
|
+
return this._cloneInto();
|
|
140
|
+
}
|
|
141
|
+
protected keccak(): void {
|
|
142
|
+
swap32IfBE(this.state32);
|
|
143
|
+
keccakP(this.state32, this.rounds);
|
|
144
|
+
swap32IfBE(this.state32);
|
|
145
|
+
this.posOut = 0;
|
|
146
|
+
this.pos = 0;
|
|
147
|
+
}
|
|
148
|
+
update(data: Input): this {
|
|
149
|
+
aexists(this);
|
|
150
|
+
data = toBytes(data);
|
|
151
|
+
abytes(data);
|
|
152
|
+
const { blockLen, state } = this;
|
|
153
|
+
const len = data.length;
|
|
154
|
+
for (let pos = 0; pos < len; ) {
|
|
155
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
156
|
+
for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++];
|
|
157
|
+
if (this.pos === blockLen) this.keccak();
|
|
158
|
+
}
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
protected finish(): void {
|
|
162
|
+
if (this.finished) return;
|
|
163
|
+
this.finished = true;
|
|
164
|
+
const { state, suffix, pos, blockLen } = this;
|
|
165
|
+
// Do the padding
|
|
166
|
+
state[pos] ^= suffix;
|
|
167
|
+
if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak();
|
|
168
|
+
state[blockLen - 1] ^= 0x80;
|
|
169
|
+
this.keccak();
|
|
170
|
+
}
|
|
171
|
+
protected writeInto(out: Uint8Array): Uint8Array {
|
|
172
|
+
aexists(this, false);
|
|
173
|
+
abytes(out);
|
|
174
|
+
this.finish();
|
|
175
|
+
const bufferOut = this.state;
|
|
176
|
+
const { blockLen } = this;
|
|
177
|
+
for (let pos = 0, len = out.length; pos < len; ) {
|
|
178
|
+
if (this.posOut >= blockLen) this.keccak();
|
|
179
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
180
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
181
|
+
this.posOut += take;
|
|
182
|
+
pos += take;
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
xofInto(out: Uint8Array): Uint8Array {
|
|
187
|
+
// Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
|
|
188
|
+
if (!this.enableXOF) throw new Error('XOF is not possible for this instance');
|
|
189
|
+
return this.writeInto(out);
|
|
190
|
+
}
|
|
191
|
+
xof(bytes: number): Uint8Array {
|
|
192
|
+
anumber(bytes);
|
|
193
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
194
|
+
}
|
|
195
|
+
digestInto(out: Uint8Array): Uint8Array {
|
|
196
|
+
aoutput(out, this);
|
|
197
|
+
if (this.finished) throw new Error('digest() was already called');
|
|
198
|
+
this.writeInto(out);
|
|
199
|
+
this.destroy();
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
digest(): Uint8Array {
|
|
203
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
204
|
+
}
|
|
205
|
+
destroy(): void {
|
|
206
|
+
this.destroyed = true;
|
|
207
|
+
clean(this.state);
|
|
208
|
+
}
|
|
209
|
+
_cloneInto(to?: Keccak): Keccak {
|
|
210
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
211
|
+
to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
|
|
212
|
+
to.state32.set(this.state32);
|
|
213
|
+
to.pos = this.pos;
|
|
214
|
+
to.posOut = this.posOut;
|
|
215
|
+
to.finished = this.finished;
|
|
216
|
+
to.rounds = rounds;
|
|
217
|
+
// Suffix can change in cSHAKE
|
|
218
|
+
to.suffix = suffix;
|
|
219
|
+
to.outputLen = outputLen;
|
|
220
|
+
to.enableXOF = enableXOF;
|
|
221
|
+
to.destroyed = this.destroyed;
|
|
222
|
+
return to;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const gen = (suffix: number, blockLen: number, outputLen: number) =>
|
|
227
|
+
createHasher(() => new Keccak(blockLen, suffix, outputLen));
|
|
228
|
+
|
|
229
|
+
/** SHA3-224 hash function. */
|
|
230
|
+
export const sha3_224: CHash = /* @__PURE__ */ (() => gen(0x06, 144, 224 / 8))();
|
|
231
|
+
/** SHA3-256 hash function. Different from keccak-256. */
|
|
232
|
+
export const sha3_256: CHash = /* @__PURE__ */ (() => gen(0x06, 136, 256 / 8))();
|
|
233
|
+
/** SHA3-384 hash function. */
|
|
234
|
+
export const sha3_384: CHash = /* @__PURE__ */ (() => gen(0x06, 104, 384 / 8))();
|
|
235
|
+
/** SHA3-512 hash function. */
|
|
236
|
+
export const sha3_512: CHash = /* @__PURE__ */ (() => gen(0x06, 72, 512 / 8))();
|
|
237
|
+
|
|
238
|
+
/** keccak-224 hash function. */
|
|
239
|
+
export const keccak_224: CHash = /* @__PURE__ */ (() => gen(0x01, 144, 224 / 8))();
|
|
240
|
+
/** keccak-256 hash function. Different from SHA3-256. */
|
|
241
|
+
export const keccak_256: CHash = /* @__PURE__ */ (() => gen(0x01, 136, 256 / 8))();
|
|
242
|
+
/** keccak-384 hash function. */
|
|
243
|
+
export const keccak_384: CHash = /* @__PURE__ */ (() => gen(0x01, 104, 384 / 8))();
|
|
244
|
+
/** keccak-512 hash function. */
|
|
245
|
+
export const keccak_512: CHash = /* @__PURE__ */ (() => gen(0x01, 72, 512 / 8))();
|
|
246
|
+
|
|
247
|
+
export type ShakeOpts = { dkLen?: number };
|
|
248
|
+
|
|
249
|
+
const genShake = (suffix: number, blockLen: number, outputLen: number) =>
|
|
250
|
+
createXOFer<HashXOF<Keccak>, ShakeOpts>(
|
|
251
|
+
(opts: ShakeOpts = {}) =>
|
|
252
|
+
new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
/** SHAKE128 XOF with 128-bit security. */
|
|
256
|
+
export const shake128: CHashXO = /* @__PURE__ */ (() => genShake(0x1f, 168, 128 / 8))();
|
|
257
|
+
/** SHAKE256 XOF with 256-bit security. */
|
|
258
|
+
export const shake256: CHashXO = /* @__PURE__ */ (() => genShake(0x1f, 136, 256 / 8))();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow.
|
|
3
|
+
*
|
|
4
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
5
|
+
* [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).
|
|
6
|
+
* @module
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
SHA384 as SHA384n,
|
|
11
|
+
sha384 as sha384n,
|
|
12
|
+
sha512_224 as sha512_224n,
|
|
13
|
+
SHA512_224 as SHA512_224n,
|
|
14
|
+
sha512_256 as sha512_256n,
|
|
15
|
+
SHA512_256 as SHA512_256n,
|
|
16
|
+
SHA512 as SHA512n,
|
|
17
|
+
sha512 as sha512n,
|
|
18
|
+
} from './sha2.ts';
|
|
19
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
20
|
+
export const SHA512: typeof SHA512n = SHA512n;
|
|
21
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
22
|
+
export const sha512: typeof sha512n = sha512n;
|
|
23
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
24
|
+
export const SHA384: typeof SHA384n = SHA384n;
|
|
25
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
26
|
+
export const sha384: typeof sha384n = sha384n;
|
|
27
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
28
|
+
export const SHA512_224: typeof SHA512_224n = SHA512_224n;
|
|
29
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
30
|
+
export const sha512_224: typeof sha512_224n = sha512_224n;
|
|
31
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
32
|
+
export const SHA512_256: typeof SHA512_256n = SHA512_256n;
|
|
33
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
34
|
+
export const sha512_256: typeof sha512_256n = sha512_256n;
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
|
+
|
|
7
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
8
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
|
9
|
+
// For node.js, package.json#exports field mapping rewrites import
|
|
10
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
|
11
|
+
// Makes the utils un-importable in browsers without a bundler.
|
|
12
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
13
|
+
import { crypto } from '@noble/hashes/crypto';
|
|
14
|
+
|
|
15
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
16
|
+
export function isBytes(a: unknown): a is Uint8Array {
|
|
17
|
+
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Asserts something is positive integer. */
|
|
21
|
+
export function anumber(n: number): void {
|
|
22
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Asserts something is Uint8Array. */
|
|
26
|
+
export function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {
|
|
27
|
+
if (!isBytes(b)) throw new Error('Uint8Array expected');
|
|
28
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
29
|
+
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Asserts something is hash */
|
|
33
|
+
export function ahash(h: IHash): void {
|
|
34
|
+
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
35
|
+
throw new Error('Hash should be wrapped by utils.createHasher');
|
|
36
|
+
anumber(h.outputLen);
|
|
37
|
+
anumber(h.blockLen);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
41
|
+
export function aexists(instance: any, checkFinished = true): void {
|
|
42
|
+
if (instance.destroyed) throw new Error('Hash instance has been destroyed');
|
|
43
|
+
if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Asserts output is properly-sized byte array */
|
|
47
|
+
export function aoutput(out: any, instance: any): void {
|
|
48
|
+
abytes(out);
|
|
49
|
+
const min = instance.outputLen;
|
|
50
|
+
if (out.length < min) {
|
|
51
|
+
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */
|
|
56
|
+
// prettier-ignore
|
|
57
|
+
export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |
|
|
58
|
+
Uint16Array | Int16Array | Uint32Array | Int32Array;
|
|
59
|
+
|
|
60
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
61
|
+
export function u8(arr: TypedArray): Uint8Array {
|
|
62
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
66
|
+
export function u32(arr: TypedArray): Uint32Array {
|
|
67
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
71
|
+
export function clean(...arrays: TypedArray[]): void {
|
|
72
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
73
|
+
arrays[i].fill(0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
78
|
+
export function createView(arr: TypedArray): DataView {
|
|
79
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
83
|
+
export function rotr(word: number, shift: number): number {
|
|
84
|
+
return (word << (32 - shift)) | (word >>> shift);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
88
|
+
export function rotl(word: number, shift: number): number {
|
|
89
|
+
return (word << shift) | ((word >>> (32 - shift)) >>> 0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
93
|
+
export const isLE: boolean = /* @__PURE__ */ (() =>
|
|
94
|
+
new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
95
|
+
|
|
96
|
+
/** The byte swap operation for uint32 */
|
|
97
|
+
export function byteSwap(word: number): number {
|
|
98
|
+
return (
|
|
99
|
+
((word << 24) & 0xff000000) |
|
|
100
|
+
((word << 8) & 0xff0000) |
|
|
101
|
+
((word >>> 8) & 0xff00) |
|
|
102
|
+
((word >>> 24) & 0xff)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
106
|
+
export const swap8IfBE: (n: number) => number = isLE
|
|
107
|
+
? (n: number) => n
|
|
108
|
+
: (n: number) => byteSwap(n);
|
|
109
|
+
|
|
110
|
+
/** @deprecated */
|
|
111
|
+
export const byteSwapIfBE: typeof swap8IfBE = swap8IfBE;
|
|
112
|
+
/** In place byte swap for Uint32Array */
|
|
113
|
+
export function byteSwap32(arr: Uint32Array): Uint32Array {
|
|
114
|
+
for (let i = 0; i < arr.length; i++) {
|
|
115
|
+
arr[i] = byteSwap(arr[i]);
|
|
116
|
+
}
|
|
117
|
+
return arr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE
|
|
121
|
+
? (u: Uint32Array) => u
|
|
122
|
+
: byteSwap32;
|
|
123
|
+
|
|
124
|
+
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
125
|
+
const hasHexBuiltin: boolean = /* @__PURE__ */ (() =>
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
|
|
128
|
+
|
|
129
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
130
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>
|
|
131
|
+
i.toString(16).padStart(2, '0')
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
136
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
137
|
+
*/
|
|
138
|
+
export function bytesToHex(bytes: Uint8Array): string {
|
|
139
|
+
abytes(bytes);
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
if (hasHexBuiltin) return bytes.toHex();
|
|
142
|
+
// pre-caching improves the speed 6x
|
|
143
|
+
let hex = '';
|
|
144
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
145
|
+
hex += hexes[bytes[i]];
|
|
146
|
+
}
|
|
147
|
+
return hex;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// We use optimized technique to convert hex string to byte array
|
|
151
|
+
const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;
|
|
152
|
+
function asciiToBase16(ch: number): number | undefined {
|
|
153
|
+
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48
|
|
154
|
+
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)
|
|
155
|
+
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
161
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
162
|
+
*/
|
|
163
|
+
export function hexToBytes(hex: string): Uint8Array {
|
|
164
|
+
if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
if (hasHexBuiltin) return Uint8Array.fromHex(hex);
|
|
167
|
+
const hl = hex.length;
|
|
168
|
+
const al = hl / 2;
|
|
169
|
+
if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);
|
|
170
|
+
const array = new Uint8Array(al);
|
|
171
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
172
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
173
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
174
|
+
if (n1 === undefined || n2 === undefined) {
|
|
175
|
+
const char = hex[hi] + hex[hi + 1];
|
|
176
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
177
|
+
}
|
|
178
|
+
array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
|
|
179
|
+
}
|
|
180
|
+
return array;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
185
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
186
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
187
|
+
*/
|
|
188
|
+
export const nextTick = async (): Promise<void> => {};
|
|
189
|
+
|
|
190
|
+
/** Returns control to thread each 'tick' ms to avoid blocking. */
|
|
191
|
+
export async function asyncLoop(
|
|
192
|
+
iters: number,
|
|
193
|
+
tick: number,
|
|
194
|
+
cb: (i: number) => void
|
|
195
|
+
): Promise<void> {
|
|
196
|
+
let ts = Date.now();
|
|
197
|
+
for (let i = 0; i < iters; i++) {
|
|
198
|
+
cb(i);
|
|
199
|
+
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
|
|
200
|
+
const diff = Date.now() - ts;
|
|
201
|
+
if (diff >= 0 && diff < tick) continue;
|
|
202
|
+
await nextTick();
|
|
203
|
+
ts += diff;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535
|
|
208
|
+
declare const TextEncoder: any;
|
|
209
|
+
declare const TextDecoder: any;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts string to bytes using UTF8 encoding.
|
|
213
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
214
|
+
*/
|
|
215
|
+
export function utf8ToBytes(str: string): Uint8Array {
|
|
216
|
+
if (typeof str !== 'string') throw new Error('string expected');
|
|
217
|
+
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Converts bytes to string using UTF8 encoding.
|
|
222
|
+
* @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
|
|
223
|
+
*/
|
|
224
|
+
export function bytesToUtf8(bytes: Uint8Array): string {
|
|
225
|
+
return new TextDecoder().decode(bytes);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Accepted input of hash functions. Strings are converted to byte arrays. */
|
|
229
|
+
export type Input = string | Uint8Array;
|
|
230
|
+
/**
|
|
231
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
232
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
233
|
+
* Keep in mind for future mutable operations.
|
|
234
|
+
*/
|
|
235
|
+
export function toBytes(data: Input): Uint8Array {
|
|
236
|
+
if (typeof data === 'string') data = utf8ToBytes(data);
|
|
237
|
+
abytes(data);
|
|
238
|
+
return data;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** KDFs can accept string or Uint8Array for user convenience. */
|
|
242
|
+
export type KDFInput = string | Uint8Array;
|
|
243
|
+
/**
|
|
244
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
245
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
246
|
+
*/
|
|
247
|
+
export function kdfInputToBytes(data: KDFInput): Uint8Array {
|
|
248
|
+
if (typeof data === 'string') data = utf8ToBytes(data);
|
|
249
|
+
abytes(data);
|
|
250
|
+
return data;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Copies several Uint8Arrays into one. */
|
|
254
|
+
export function concatBytes(...arrays: Uint8Array[]): Uint8Array {
|
|
255
|
+
let sum = 0;
|
|
256
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
257
|
+
const a = arrays[i];
|
|
258
|
+
abytes(a);
|
|
259
|
+
sum += a.length;
|
|
260
|
+
}
|
|
261
|
+
const res = new Uint8Array(sum);
|
|
262
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
263
|
+
const a = arrays[i];
|
|
264
|
+
res.set(a, pad);
|
|
265
|
+
pad += a.length;
|
|
266
|
+
}
|
|
267
|
+
return res;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
type EmptyObj = {};
|
|
271
|
+
export function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(
|
|
272
|
+
defaults: T1,
|
|
273
|
+
opts?: T2
|
|
274
|
+
): T1 & T2 {
|
|
275
|
+
if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
|
|
276
|
+
throw new Error('options should be object or undefined');
|
|
277
|
+
const merged = Object.assign(defaults, opts);
|
|
278
|
+
return merged as T1 & T2;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Hash interface. */
|
|
282
|
+
export type IHash = {
|
|
283
|
+
(data: Uint8Array): Uint8Array;
|
|
284
|
+
blockLen: number;
|
|
285
|
+
outputLen: number;
|
|
286
|
+
create: any;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/** For runtime check if class implements interface */
|
|
290
|
+
export abstract class Hash<T extends Hash<T>> {
|
|
291
|
+
abstract blockLen: number; // Bytes per block
|
|
292
|
+
abstract outputLen: number; // Bytes in output
|
|
293
|
+
abstract update(buf: Input): this;
|
|
294
|
+
// Writes digest into buf
|
|
295
|
+
abstract digestInto(buf: Uint8Array): void;
|
|
296
|
+
abstract digest(): Uint8Array;
|
|
297
|
+
/**
|
|
298
|
+
* Resets internal state. Makes Hash instance unusable.
|
|
299
|
+
* Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed
|
|
300
|
+
* by user, they will need to manually call `destroy()` when zeroing is necessary.
|
|
301
|
+
*/
|
|
302
|
+
abstract destroy(): void;
|
|
303
|
+
/**
|
|
304
|
+
* Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`
|
|
305
|
+
* when no options are passed.
|
|
306
|
+
* Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal
|
|
307
|
+
* buffers are overwritten => causes buffer overwrite which is used for digest in some cases.
|
|
308
|
+
* There are no guarantees for clean-up because it's impossible in JS.
|
|
309
|
+
*/
|
|
310
|
+
abstract _cloneInto(to?: T): T;
|
|
311
|
+
// Safe version that clones internal state
|
|
312
|
+
abstract clone(): T;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* XOF: streaming API to read digest in chunks.
|
|
317
|
+
* Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.
|
|
318
|
+
* When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot
|
|
319
|
+
* destroy state, next call can require more bytes.
|
|
320
|
+
*/
|
|
321
|
+
export type HashXOF<T extends Hash<T>> = Hash<T> & {
|
|
322
|
+
xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream
|
|
323
|
+
xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/** Hash function */
|
|
327
|
+
export type CHash = ReturnType<typeof createHasher>;
|
|
328
|
+
/** Hash function with output */
|
|
329
|
+
export type CHashO = ReturnType<typeof createOptHasher>;
|
|
330
|
+
/** XOF with output */
|
|
331
|
+
export type CHashXO = ReturnType<typeof createXOFer>;
|
|
332
|
+
|
|
333
|
+
/** Wraps hash function, creating an interface on top of it */
|
|
334
|
+
export function createHasher<T extends Hash<T>>(
|
|
335
|
+
hashCons: () => Hash<T>
|
|
336
|
+
): {
|
|
337
|
+
(msg: Input): Uint8Array;
|
|
338
|
+
outputLen: number;
|
|
339
|
+
blockLen: number;
|
|
340
|
+
create(): Hash<T>;
|
|
341
|
+
} {
|
|
342
|
+
const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();
|
|
343
|
+
const tmp = hashCons();
|
|
344
|
+
hashC.outputLen = tmp.outputLen;
|
|
345
|
+
hashC.blockLen = tmp.blockLen;
|
|
346
|
+
hashC.create = () => hashCons();
|
|
347
|
+
return hashC;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function createOptHasher<H extends Hash<H>, T extends Object>(
|
|
351
|
+
hashCons: (opts?: T) => Hash<H>
|
|
352
|
+
): {
|
|
353
|
+
(msg: Input, opts?: T): Uint8Array;
|
|
354
|
+
outputLen: number;
|
|
355
|
+
blockLen: number;
|
|
356
|
+
create(opts?: T): Hash<H>;
|
|
357
|
+
} {
|
|
358
|
+
const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();
|
|
359
|
+
const tmp = hashCons({} as T);
|
|
360
|
+
hashC.outputLen = tmp.outputLen;
|
|
361
|
+
hashC.blockLen = tmp.blockLen;
|
|
362
|
+
hashC.create = (opts?: T) => hashCons(opts);
|
|
363
|
+
return hashC;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function createXOFer<H extends HashXOF<H>, T extends Object>(
|
|
367
|
+
hashCons: (opts?: T) => HashXOF<H>
|
|
368
|
+
): {
|
|
369
|
+
(msg: Input, opts?: T): Uint8Array;
|
|
370
|
+
outputLen: number;
|
|
371
|
+
blockLen: number;
|
|
372
|
+
create(opts?: T): HashXOF<H>;
|
|
373
|
+
} {
|
|
374
|
+
const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();
|
|
375
|
+
const tmp = hashCons({} as T);
|
|
376
|
+
hashC.outputLen = tmp.outputLen;
|
|
377
|
+
hashC.blockLen = tmp.blockLen;
|
|
378
|
+
hashC.create = (opts?: T) => hashCons(opts);
|
|
379
|
+
return hashC;
|
|
380
|
+
}
|
|
381
|
+
export const wrapConstructor: typeof createHasher = createHasher;
|
|
382
|
+
export const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher;
|
|
383
|
+
export const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer;
|
|
384
|
+
|
|
385
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
386
|
+
export function randomBytes(bytesLength = 32): Uint8Array {
|
|
387
|
+
if (crypto && typeof crypto.getRandomValues === 'function') {
|
|
388
|
+
return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
389
|
+
}
|
|
390
|
+
// Legacy Node.js compatibility
|
|
391
|
+
if (crypto && typeof crypto.randomBytes === 'function') {
|
|
392
|
+
return Uint8Array.from(crypto.randomBytes(bytesLength));
|
|
393
|
+
}
|
|
394
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
395
|
+
}
|