@weavecode/weave 0.1.0 → 0.1.1
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/node_modules/@weavecode/cli/dist/cli.js +4 -4
- package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/dashboard.d.ts +0 -2
- package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -1
- package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/msg.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
- package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +5 -3
- package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +44 -1
- package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +6 -4
- package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
- package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +4 -4
- package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
- package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
- package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
- package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/helpers-gen.d.ts +4 -0
- package/node_modules/@weavecode/cli/dist/init/helpers-gen.js +1 -20
- package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/mcp-gen.d.ts +3 -20
- package/node_modules/@weavecode/cli/dist/init/mcp-gen.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
- package/node_modules/@weavecode/cli/dist/init/settings-gen.d.ts +3 -30
- package/node_modules/@weavecode/cli/dist/init/settings-gen.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
- package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
- package/node_modules/@weavecode/cli/dist/parser.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
- package/node_modules/@weavecode/cli/package.json +5 -5
- package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
- package/node_modules/@weavecode/core/dist/harness.d.ts +45 -2
- package/node_modules/@weavecode/core/dist/harness.js +1 -1
- package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
- package/node_modules/@weavecode/core/dist/index.js +1 -1
- package/node_modules/@weavecode/core/dist/platform.js +1 -1
- package/node_modules/@weavecode/core/dist/terminal.d.ts +28 -4
- package/node_modules/@weavecode/core/dist/terminal.js +1 -1
- package/node_modules/@weavecode/core/dist/types.d.ts +188 -11
- package/node_modules/@weavecode/core/dist/types.js +1 -1
- package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
- package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
- package/node_modules/@weavecode/core/package.json +1 -1
- package/node_modules/@weavecode/harness/dist/claude/assets.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/capture.d.ts +11 -1
- package/node_modules/@weavecode/harness/dist/claude/capture.js +5 -5
- package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/event-source.d.ts +1 -1
- package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/helpers-gen.d.ts +5 -0
- package/node_modules/@weavecode/harness/dist/claude/helpers-gen.js +20 -0
- package/node_modules/@weavecode/harness/dist/claude/index.d.ts +5 -1
- package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/mcp-gen.d.ts +22 -0
- package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -0
- package/node_modules/@weavecode/harness/dist/claude/messaging.d.ts +11 -2
- package/node_modules/@weavecode/harness/dist/claude/messaging.js +4 -1
- package/node_modules/@weavecode/harness/dist/claude/model-aliases.d.ts +25 -0
- package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -0
- package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
- package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
- package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -1
- package/node_modules/@weavecode/harness/dist/claude/settings-gen.d.ts +32 -0
- package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -0
- package/node_modules/@weavecode/harness/dist/claude/transcript.d.ts +16 -0
- package/node_modules/@weavecode/harness/dist/claude/transcript.js +4 -2
- package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/messaging.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/toml.js +9 -9
- package/node_modules/@weavecode/harness/dist/driver.d.ts +58 -1
- package/node_modules/@weavecode/harness/dist/driver.js +1 -1
- package/node_modules/@weavecode/harness/dist/index.d.ts +1 -0
- package/node_modules/@weavecode/harness/dist/index.js +1 -1
- package/node_modules/@weavecode/harness/dist/init/generated.d.ts +37 -0
- package/node_modules/@weavecode/harness/dist/init/generated.js +2 -0
- package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
- package/node_modules/@weavecode/harness/dist/registry-wiring.d.ts +3 -1
- package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
- package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
- package/node_modules/@weavecode/harness/package.json +2 -2
- package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
- package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
- package/node_modules/@weavecode/server/dist/daemon/api-log.d.ts +48 -0
- package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -0
- package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/auto-start.js +6 -6
- package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/claude-liveness.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/data-bus.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.d.ts +6 -1
- package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/opener.d.ts +102 -19
- package/node_modules/@weavecode/server/dist/daemon/opener.js +97 -7
- package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.d.ts +4 -3
- package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/server.d.ts +8 -0
- package/node_modules/@weavecode/server/dist/daemon/server.js +6 -6
- package/node_modules/@weavecode/server/dist/daemon/session-probe.d.ts +59 -2
- package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/settings.d.ts +10 -0
- package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.d.ts +4 -1
- package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/db/db.js +20 -2
- package/node_modules/@weavecode/server/dist/db/paths.d.ts +4 -0
- package/node_modules/@weavecode/server/dist/db/paths.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/bus.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
- package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
- package/node_modules/@weavecode/server/dist/hooks/inbox-socket.d.ts +17 -4
- package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -1
- package/node_modules/@weavecode/server/dist/hooks/inbox-worker.d.ts +20 -6
- package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
- package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +171 -13
- package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +3 -2
- package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
- package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
- package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/promptbox.d.ts +13 -0
- package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
- package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
- package/node_modules/@weavecode/server/dist/hooks/question-tracker.d.ts +6 -4
- package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/sequence-engine.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/session-purge.d.ts +4 -0
- package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/session-sweeper.d.ts +5 -8
- package/node_modules/@weavecode/server/dist/hooks/session-sweeper.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/toolkit.d.ts +8 -0
- package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
- package/node_modules/@weavecode/server/dist/hooks/watch-engine.d.ts +7 -0
- package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
- package/node_modules/@weavecode/server/dist/index.d.ts +1 -1
- package/node_modules/@weavecode/server/dist/install/apply-update.d.ts +1 -1
- package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
- package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
- package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
- package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
- package/node_modules/@weavecode/server/dist/install/fingerprint.d.ts +5 -1
- package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
- package/node_modules/@weavecode/server/dist/install/git-classify.d.ts +30 -0
- package/node_modules/@weavecode/server/dist/install/git-classify.js +1 -0
- package/node_modules/@weavecode/server/dist/install/global-config.js +2 -2
- package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
- package/node_modules/@weavecode/server/dist/install/init-files.d.ts +46 -0
- package/node_modules/@weavecode/server/dist/install/init-files.js +2 -0
- package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
- package/node_modules/@weavecode/server/dist/install/installer.js +3 -3
- package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
- package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
- package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
- package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
- package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
- package/node_modules/@weavecode/server/dist/install/project-config.d.ts +0 -2
- package/node_modules/@weavecode/server/dist/install/project-config.js +2 -2
- package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
- package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
- package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
- package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
- package/node_modules/@weavecode/server/dist/install/updates.d.ts +17 -5
- package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
- package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
- package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
- package/node_modules/@weavecode/server/dist/market/import.js +2 -2
- package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
- package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
- package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
- package/node_modules/@weavecode/server/dist/registry.js +2 -2
- package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +5 -5
- package/node_modules/@weavecode/server/dist/repositories/hook-events.js +2 -2
- package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
- package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
- package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
- package/node_modules/@weavecode/server/dist/repositories/projects.d.ts +7 -0
- package/node_modules/@weavecode/server/dist/repositories/projects.js +2 -2
- package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
- package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
- package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +17 -4
- package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
- package/node_modules/@weavecode/server/dist/repositories/uploads.d.ts +66 -0
- package/node_modules/@weavecode/server/dist/repositories/uploads.js +7 -0
- package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
- package/node_modules/@weavecode/server/dist/statusline/generator.js +81 -40
- package/node_modules/@weavecode/server/dist/statusline/manager.d.ts +2 -0
- package/node_modules/@weavecode/server/dist/statusline/manager.js +4 -4
- package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
- package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
- package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
- package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
- package/node_modules/@weavecode/server/dist/watch/sync-scheduler.d.ts +8 -4
- package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
- package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
- package/node_modules/@weavecode/server/package.json +4 -4
- package/node_modules/@weavecode/server/web/dist/assets/index-D5WFh77i.css +11 -0
- package/node_modules/@weavecode/server/web/dist/assets/index-DJibaGnJ.js +585 -0
- package/node_modules/@weavecode/server/web/dist/index.html +14 -2
- package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-plugin-creator/skills/weave-plugin-creator/SKILL.md +2 -2
- package/node_modules/@weavecode/templates/package.json +2 -2
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/package.json +20 -17
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/README.md +50 -32
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.d.ts +86 -40
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.es.js +860 -353
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.js +860 -353
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/package.json +20 -17
- package/package.json +6 -6
- package/node_modules/@weavecode/server/web/dist/assets/index-BOzaRlQE.js +0 -560
- package/node_modules/@weavecode/server/web/dist/assets/index-ChX8G8cT.css +0 -11
|
@@ -72,7 +72,7 @@ function concat(buffers) {
|
|
|
72
72
|
const retView = new Uint8Array(outputLength);
|
|
73
73
|
for (let i = 0; i < buffers.length; i++) {
|
|
74
74
|
const buffer = buffers[i];
|
|
75
|
-
retView.set(new Uint8Array(buffer), prevLength);
|
|
75
|
+
retView.set(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer), prevLength);
|
|
76
76
|
prevLength += buffer.byteLength;
|
|
77
77
|
}
|
|
78
78
|
return retView.buffer;
|
|
@@ -94,7 +94,7 @@ function checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength) {
|
|
|
94
94
|
baseBlock.error = "Wrong parameter: inputLength less than zero";
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
|
-
if (
|
|
97
|
+
if (inputBuffer.byteLength - inputOffset - inputLength < 0) {
|
|
98
98
|
baseBlock.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
@@ -106,15 +106,15 @@ class ViewWriter {
|
|
|
106
106
|
this.items = [];
|
|
107
107
|
}
|
|
108
108
|
write(buf) {
|
|
109
|
-
this.items.push(buf);
|
|
109
|
+
this.items.push(buf instanceof ArrayBuffer ? buf : concat([buf]));
|
|
110
110
|
}
|
|
111
111
|
final() {
|
|
112
112
|
return concat(this.items);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
const ORIGINAL_VIEW_WRITER_WRITE = ViewWriter.prototype.write;
|
|
116
|
+
const ORIGINAL_VIEW_WRITER_FINAL = ViewWriter.prototype.final;
|
|
115
117
|
|
|
116
|
-
const powers2 = [new Uint8Array([1])];
|
|
117
|
-
const digitsString = "0123456789";
|
|
118
118
|
const NAME = "name";
|
|
119
119
|
const VALUE_HEX_VIEW = "valueHexView";
|
|
120
120
|
const IS_HEX_ONLY = "isHexOnly";
|
|
@@ -170,15 +170,17 @@ function HexBlock(BaseClass) {
|
|
|
170
170
|
if (sizeOnly) {
|
|
171
171
|
return new ArrayBuffer(this.valueHexView.byteLength);
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
if (this.valueHexView.buffer instanceof ArrayBuffer &&
|
|
174
|
+
this.valueHexView.byteLength === this.valueHexView.buffer.byteLength) {
|
|
175
|
+
return this.valueHexView.buffer;
|
|
176
|
+
}
|
|
177
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(this.valueHexView);
|
|
176
178
|
}
|
|
177
179
|
toJSON() {
|
|
178
180
|
return {
|
|
179
181
|
...super.toJSON(),
|
|
180
182
|
isHexOnly: this.isHexOnly,
|
|
181
|
-
valueHex: pvtsutils__namespace.Convert.ToHex(this.valueHexView)
|
|
183
|
+
valueHex: pvtsutils__namespace.Convert.ToHex(this.valueHexView)
|
|
182
184
|
};
|
|
183
185
|
}
|
|
184
186
|
},
|
|
@@ -196,7 +198,7 @@ class LocalBaseBlock {
|
|
|
196
198
|
set valueBeforeDecode(value) {
|
|
197
199
|
this.valueBeforeDecodeView = new Uint8Array(value);
|
|
198
200
|
}
|
|
199
|
-
constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW
|
|
201
|
+
constructor({ blockLength = 0, error = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW } = {}) {
|
|
200
202
|
this.blockLength = blockLength;
|
|
201
203
|
this.error = error;
|
|
202
204
|
this.warnings = warnings;
|
|
@@ -208,7 +210,7 @@ class LocalBaseBlock {
|
|
|
208
210
|
blockLength: this.blockLength,
|
|
209
211
|
error: this.error,
|
|
210
212
|
warnings: this.warnings,
|
|
211
|
-
valueBeforeDecode: pvtsutils__namespace.Convert.ToHex(this.valueBeforeDecodeView)
|
|
213
|
+
valueBeforeDecode: pvtsutils__namespace.Convert.ToHex(this.valueBeforeDecodeView)
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
216
|
}
|
|
@@ -256,7 +258,7 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
256
258
|
firstOctet |= 0x80;
|
|
257
259
|
break;
|
|
258
260
|
case 4:
|
|
259
|
-
firstOctet |=
|
|
261
|
+
firstOctet |= 0xc0;
|
|
260
262
|
break;
|
|
261
263
|
default:
|
|
262
264
|
this.error = "Unknown tag class";
|
|
@@ -268,7 +270,7 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
268
270
|
const retView = new Uint8Array(1);
|
|
269
271
|
if (!sizeOnly) {
|
|
270
272
|
let number = this.tagNumber;
|
|
271
|
-
number &=
|
|
273
|
+
number &= 0x1f;
|
|
272
274
|
firstOctet |= number;
|
|
273
275
|
retView[0] = firstOctet;
|
|
274
276
|
}
|
|
@@ -279,19 +281,19 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
279
281
|
const encodedView = new Uint8Array(encodedBuf);
|
|
280
282
|
const size = encodedBuf.byteLength;
|
|
281
283
|
const retView = new Uint8Array(size + 1);
|
|
282
|
-
retView[0] =
|
|
284
|
+
retView[0] = firstOctet | 0x1f;
|
|
283
285
|
if (!sizeOnly) {
|
|
284
|
-
for (let i = 0; i <
|
|
286
|
+
for (let i = 0; i < size - 1; i++)
|
|
285
287
|
retView[i + 1] = encodedView[i] | 0x80;
|
|
286
288
|
retView[size] = encodedView[size - 1];
|
|
287
289
|
}
|
|
288
290
|
return retView.buffer;
|
|
289
291
|
}
|
|
290
292
|
const retView = new Uint8Array(this.valueHexView.byteLength + 1);
|
|
291
|
-
retView[0] =
|
|
293
|
+
retView[0] = firstOctet | 0x1f;
|
|
292
294
|
if (!sizeOnly) {
|
|
293
295
|
const curView = this.valueHexView;
|
|
294
|
-
for (let i = 0; i <
|
|
296
|
+
for (let i = 0; i < curView.length - 1; i++)
|
|
295
297
|
retView[i + 1] = curView[i] | 0x80;
|
|
296
298
|
retView[this.valueHexView.byteLength] = curView[curView.length - 1];
|
|
297
299
|
}
|
|
@@ -302,52 +304,55 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
302
304
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength)) {
|
|
303
305
|
return -1;
|
|
304
306
|
}
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
+
const fastArgs = Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
308
|
+
const intBuffer = fastArgs ? inputView : inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
309
|
+
const baseIndex = fastArgs ? inputOffset : 0;
|
|
310
|
+
const bufferLength = fastArgs ? inputLength : intBuffer.length;
|
|
311
|
+
if (bufferLength === 0) {
|
|
307
312
|
this.error = "Zero buffer length";
|
|
308
313
|
return -1;
|
|
309
314
|
}
|
|
310
|
-
const tagClassMask = intBuffer[
|
|
315
|
+
const tagClassMask = intBuffer[baseIndex] & 0xc0;
|
|
311
316
|
switch (tagClassMask) {
|
|
312
317
|
case 0x00:
|
|
313
|
-
this.tagClass =
|
|
318
|
+
this.tagClass = 1;
|
|
314
319
|
break;
|
|
315
320
|
case 0x40:
|
|
316
|
-
this.tagClass =
|
|
321
|
+
this.tagClass = 2;
|
|
317
322
|
break;
|
|
318
323
|
case 0x80:
|
|
319
|
-
this.tagClass =
|
|
324
|
+
this.tagClass = 3;
|
|
320
325
|
break;
|
|
321
|
-
case
|
|
322
|
-
this.tagClass =
|
|
326
|
+
case 0xc0:
|
|
327
|
+
this.tagClass = 4;
|
|
323
328
|
break;
|
|
324
329
|
default:
|
|
325
330
|
this.error = "Unknown tag class";
|
|
326
331
|
return -1;
|
|
327
332
|
}
|
|
328
|
-
this.isConstructed = (intBuffer[
|
|
333
|
+
this.isConstructed = (intBuffer[baseIndex] & 0x20) === 0x20;
|
|
329
334
|
this.isHexOnly = false;
|
|
330
|
-
const tagNumberMask = intBuffer[
|
|
331
|
-
if (tagNumberMask !==
|
|
332
|
-
this.tagNumber =
|
|
335
|
+
const tagNumberMask = intBuffer[baseIndex] & 0x1f;
|
|
336
|
+
if (tagNumberMask !== 0x1f) {
|
|
337
|
+
this.tagNumber = tagNumberMask;
|
|
333
338
|
this.blockLength = 1;
|
|
334
339
|
}
|
|
335
340
|
else {
|
|
336
341
|
let count = 0;
|
|
337
342
|
while (true) {
|
|
338
343
|
const tagByteIndex = count + 1;
|
|
339
|
-
if (tagByteIndex >=
|
|
344
|
+
if (tagByteIndex >= bufferLength) {
|
|
340
345
|
this.error = "End of input reached before message was fully decoded";
|
|
341
346
|
return -1;
|
|
342
347
|
}
|
|
343
348
|
count++;
|
|
344
|
-
if ((intBuffer[tagByteIndex] & 0x80) === 0x00)
|
|
349
|
+
if ((intBuffer[baseIndex + tagByteIndex] & 0x80) === 0x00)
|
|
345
350
|
break;
|
|
346
351
|
}
|
|
347
|
-
this.blockLength =
|
|
348
|
-
const intTagNumberBuffer = this.valueHexView = new Uint8Array(count);
|
|
352
|
+
this.blockLength = count + 1;
|
|
353
|
+
const intTagNumberBuffer = (this.valueHexView = new Uint8Array(count));
|
|
349
354
|
for (let i = 0; i < count; i++)
|
|
350
|
-
intTagNumberBuffer[i] = intBuffer[i + 1] &
|
|
355
|
+
intTagNumberBuffer[i] = intBuffer[baseIndex + i + 1] & 0x7f;
|
|
351
356
|
if (this.blockLength <= 9)
|
|
352
357
|
this.tagNumber = pvutils__namespace.utilFromBase(intTagNumberBuffer, 7);
|
|
353
358
|
else {
|
|
@@ -355,8 +360,7 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
355
360
|
this.warnings.push("Tag too long, represented as hex-coded");
|
|
356
361
|
}
|
|
357
362
|
}
|
|
358
|
-
if (
|
|
359
|
-
&& (this.isConstructed)) {
|
|
363
|
+
if (this.tagClass === 1 && this.isConstructed) {
|
|
360
364
|
switch (this.tagNumber) {
|
|
361
365
|
case 1:
|
|
362
366
|
case 2:
|
|
@@ -375,18 +379,20 @@ class LocalIdentificationBlock extends HexBlock(LocalBaseBlock) {
|
|
|
375
379
|
return -1;
|
|
376
380
|
}
|
|
377
381
|
}
|
|
378
|
-
return
|
|
382
|
+
return inputOffset + this.blockLength;
|
|
379
383
|
}
|
|
380
384
|
toJSON() {
|
|
381
385
|
return {
|
|
382
386
|
...super.toJSON(),
|
|
383
387
|
tagClass: this.tagClass,
|
|
384
388
|
tagNumber: this.tagNumber,
|
|
385
|
-
isConstructed: this.isConstructed
|
|
389
|
+
isConstructed: this.isConstructed
|
|
386
390
|
};
|
|
387
391
|
}
|
|
388
392
|
}
|
|
389
393
|
LocalIdentificationBlock.NAME = "identificationBlock";
|
|
394
|
+
const ORIGINAL_LOCAL_IDENTIFICATION_TO_BER = LocalIdentificationBlock.prototype.toBER;
|
|
395
|
+
const ORIGINAL_LOCAL_IDENTIFICATION_FROM_BER = LocalIdentificationBlock.prototype.fromBER;
|
|
390
396
|
|
|
391
397
|
class LocalLengthBlock extends LocalBaseBlock {
|
|
392
398
|
constructor({ lenBlock = {} } = {}) {
|
|
@@ -401,32 +407,35 @@ class LocalLengthBlock extends LocalBaseBlock {
|
|
|
401
407
|
if (!checkBufferParams(this, view, inputOffset, inputLength)) {
|
|
402
408
|
return -1;
|
|
403
409
|
}
|
|
404
|
-
const
|
|
405
|
-
|
|
410
|
+
const fastArgs = Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
411
|
+
const intBuffer = fastArgs ? view : view.subarray(inputOffset, inputOffset + inputLength);
|
|
412
|
+
const baseIndex = fastArgs ? inputOffset : 0;
|
|
413
|
+
const bufferLength = fastArgs ? inputLength : intBuffer.length;
|
|
414
|
+
if (bufferLength === 0) {
|
|
406
415
|
this.error = "Zero buffer length";
|
|
407
416
|
return -1;
|
|
408
417
|
}
|
|
409
|
-
if (intBuffer[
|
|
418
|
+
if (intBuffer[baseIndex] === 0xff) {
|
|
410
419
|
this.error = "Length block 0xFF is reserved by standard";
|
|
411
420
|
return -1;
|
|
412
421
|
}
|
|
413
|
-
this.isIndefiniteForm = intBuffer[
|
|
422
|
+
this.isIndefiniteForm = intBuffer[baseIndex] === 0x80;
|
|
414
423
|
if (this.isIndefiniteForm) {
|
|
415
424
|
this.blockLength = 1;
|
|
416
|
-
return
|
|
425
|
+
return inputOffset + this.blockLength;
|
|
417
426
|
}
|
|
418
|
-
this.longFormUsed = !!(intBuffer[
|
|
427
|
+
this.longFormUsed = !!(intBuffer[baseIndex] & 0x80);
|
|
419
428
|
if (this.longFormUsed === false) {
|
|
420
|
-
this.length =
|
|
429
|
+
this.length = intBuffer[baseIndex];
|
|
421
430
|
this.blockLength = 1;
|
|
422
|
-
return
|
|
431
|
+
return inputOffset + this.blockLength;
|
|
423
432
|
}
|
|
424
|
-
const count = intBuffer[
|
|
433
|
+
const count = intBuffer[baseIndex] & 0x7f;
|
|
425
434
|
if (count > 8) {
|
|
426
435
|
this.error = "Too big integer";
|
|
427
436
|
return -1;
|
|
428
437
|
}
|
|
429
|
-
if (
|
|
438
|
+
if (count + 1 > bufferLength) {
|
|
430
439
|
this.error = "End of input reached before message was fully decoded";
|
|
431
440
|
return -1;
|
|
432
441
|
}
|
|
@@ -435,10 +444,10 @@ class LocalLengthBlock extends LocalBaseBlock {
|
|
|
435
444
|
if (lengthBufferView[count - 1] === 0x00)
|
|
436
445
|
this.warnings.push("Needlessly long encoded length");
|
|
437
446
|
this.length = pvutils__namespace.utilFromBase(lengthBufferView, 8);
|
|
438
|
-
if (this.longFormUsed &&
|
|
447
|
+
if (this.longFormUsed && this.length <= 127)
|
|
439
448
|
this.warnings.push("Unnecessary usage of long length form");
|
|
440
449
|
this.blockLength = count + 1;
|
|
441
|
-
return
|
|
450
|
+
return inputOffset + this.blockLength;
|
|
442
451
|
}
|
|
443
452
|
toBER(sizeOnly = false) {
|
|
444
453
|
let retBuf;
|
|
@@ -457,7 +466,7 @@ class LocalLengthBlock extends LocalBaseBlock {
|
|
|
457
466
|
const encodedBuf = pvutils__namespace.utilToBase(this.length, 8);
|
|
458
467
|
if (encodedBuf.byteLength > 127) {
|
|
459
468
|
this.error = "Too big length";
|
|
460
|
-
return
|
|
469
|
+
return EMPTY_BUFFER;
|
|
461
470
|
}
|
|
462
471
|
retBuf = new ArrayBuffer(encodedBuf.byteLength + 1);
|
|
463
472
|
if (sizeOnly)
|
|
@@ -481,14 +490,427 @@ class LocalLengthBlock extends LocalBaseBlock {
|
|
|
481
490
|
...super.toJSON(),
|
|
482
491
|
isIndefiniteForm: this.isIndefiniteForm,
|
|
483
492
|
longFormUsed: this.longFormUsed,
|
|
484
|
-
length: this.length
|
|
493
|
+
length: this.length
|
|
485
494
|
};
|
|
486
495
|
}
|
|
487
496
|
}
|
|
488
497
|
LocalLengthBlock.NAME = "lengthBlock";
|
|
498
|
+
const ORIGINAL_LOCAL_LENGTH_TO_BER = LocalLengthBlock.prototype.toBER;
|
|
499
|
+
const ORIGINAL_LOCAL_LENGTH_FROM_BER = LocalLengthBlock.prototype.fromBER;
|
|
489
500
|
|
|
490
501
|
const typeStore = {};
|
|
491
502
|
|
|
503
|
+
var _a$y, _b, _c;
|
|
504
|
+
const originalUint8ArraySliceInfo = findMethod(Uint8Array.prototype, "slice");
|
|
505
|
+
const originalUint8ArrayConstructor = (_a$y = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor")) === null || _a$y === void 0 ? void 0 : _a$y.value;
|
|
506
|
+
const originalArrayIterator = (_b = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator)) === null || _b === void 0 ? void 0 : _b.value;
|
|
507
|
+
const intrinsicTypedArrayByteLength = (_c = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), "byteLength")) === null || _c === void 0 ? void 0 : _c.get;
|
|
508
|
+
const BUILTIN_DISPATCH_PAYLOAD_THRESHOLD = 16384;
|
|
509
|
+
const BUILTIN_DISPATCH_MAX_DEPTH = 64;
|
|
510
|
+
let builtinRegistry;
|
|
511
|
+
function registerBuiltinEncoder(builtinConstructors, internals) {
|
|
512
|
+
const current = builtinRegistry;
|
|
513
|
+
const nextInternals = internals || current;
|
|
514
|
+
if (!nextInternals) {
|
|
515
|
+
builtinRegistry = undefined;
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
builtinRegistry = { ...nextInternals, ...builtinConstructors };
|
|
519
|
+
}
|
|
520
|
+
function dataProperty(object, name) {
|
|
521
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
|
522
|
+
if (!descriptor || !("value" in descriptor))
|
|
523
|
+
return undefined;
|
|
524
|
+
return descriptor.value;
|
|
525
|
+
}
|
|
526
|
+
function intrinsicPayloadByteLength(value) {
|
|
527
|
+
if (!intrinsicTypedArrayByteLength || !value || typeof value !== "object")
|
|
528
|
+
return undefined;
|
|
529
|
+
try {
|
|
530
|
+
const byteLength = intrinsicTypedArrayByteLength.call(value);
|
|
531
|
+
return typeof byteLength === "number" ? byteLength : undefined;
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
return undefined;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function largePayloadOrChain(block, depth) {
|
|
538
|
+
if (depth > BUILTIN_DISPATCH_MAX_DEPTH || !block || typeof block !== "object")
|
|
539
|
+
return false;
|
|
540
|
+
const valueBlockDescriptor = Object.getOwnPropertyDescriptor(block, "valueBlock");
|
|
541
|
+
if (!valueBlockDescriptor || !("value" in valueBlockDescriptor))
|
|
542
|
+
return false;
|
|
543
|
+
const valueBlock = valueBlockDescriptor.value;
|
|
544
|
+
if (!valueBlock || typeof valueBlock !== "object")
|
|
545
|
+
return false;
|
|
546
|
+
const payloadDescriptor = Object.getOwnPropertyDescriptor(valueBlock, "valueHexView");
|
|
547
|
+
if (payloadDescriptor) {
|
|
548
|
+
if (!("value" in payloadDescriptor))
|
|
549
|
+
return false;
|
|
550
|
+
const byteLength = intrinsicPayloadByteLength(payloadDescriptor.value);
|
|
551
|
+
return byteLength !== undefined && byteLength >= BUILTIN_DISPATCH_PAYLOAD_THRESHOLD;
|
|
552
|
+
}
|
|
553
|
+
const valuesDescriptor = Object.getOwnPropertyDescriptor(valueBlock, "value");
|
|
554
|
+
if (!valuesDescriptor || !("value" in valuesDescriptor) || !Array.isArray(valuesDescriptor.value))
|
|
555
|
+
return false;
|
|
556
|
+
const values = valuesDescriptor.value;
|
|
557
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(values, "length");
|
|
558
|
+
if (!lengthDescriptor || !("value" in lengthDescriptor) || lengthDescriptor.value !== 1)
|
|
559
|
+
return false;
|
|
560
|
+
const indexDescriptor = Object.getOwnPropertyDescriptor(values, "0");
|
|
561
|
+
if (!indexDescriptor || !("value" in indexDescriptor))
|
|
562
|
+
return false;
|
|
563
|
+
return largePayloadOrChain(indexDescriptor.value, depth + 1);
|
|
564
|
+
}
|
|
565
|
+
function shouldUseBuiltinEncoder(block) {
|
|
566
|
+
try {
|
|
567
|
+
return largePayloadOrChain(block, 0);
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function sameDataMethod(current, original) {
|
|
574
|
+
return (!!current &&
|
|
575
|
+
"value" in current &&
|
|
576
|
+
current.value === original &&
|
|
577
|
+
current.writable === true &&
|
|
578
|
+
current.enumerable === false &&
|
|
579
|
+
current.configurable === true);
|
|
580
|
+
}
|
|
581
|
+
function writerMethodsStable(registry) {
|
|
582
|
+
return (sameDataMethod(Object.getOwnPropertyDescriptor(registry.ViewWriter.prototype, "write"), registry.originalWriterWrite) &&
|
|
583
|
+
sameDataMethod(Object.getOwnPropertyDescriptor(registry.ViewWriter.prototype, "final"), registry.originalWriterFinal));
|
|
584
|
+
}
|
|
585
|
+
function findMethod(prototype, name) {
|
|
586
|
+
let current = prototype;
|
|
587
|
+
while (current) {
|
|
588
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
589
|
+
if (descriptor) {
|
|
590
|
+
if ("value" in descriptor && typeof descriptor.value === "function") {
|
|
591
|
+
return { declaringPrototype: current, method: descriptor.value };
|
|
592
|
+
}
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
current = Object.getPrototypeOf(current);
|
|
596
|
+
}
|
|
597
|
+
return undefined;
|
|
598
|
+
}
|
|
599
|
+
function stableInheritedMethod(prototype, name, original) {
|
|
600
|
+
if (!original)
|
|
601
|
+
return false;
|
|
602
|
+
let current = prototype;
|
|
603
|
+
while (current) {
|
|
604
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
605
|
+
if (current === original.declaringPrototype) {
|
|
606
|
+
return !!descriptor && "value" in descriptor && descriptor.value === original.method;
|
|
607
|
+
}
|
|
608
|
+
if (descriptor)
|
|
609
|
+
return false;
|
|
610
|
+
current = Object.getPrototypeOf(current);
|
|
611
|
+
}
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
function prototypeMethod(object, prototype, name, expected) {
|
|
615
|
+
if (Object.prototype.hasOwnProperty.call(object, name))
|
|
616
|
+
return false;
|
|
617
|
+
if (Object.getPrototypeOf(object) !== prototype)
|
|
618
|
+
return false;
|
|
619
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
620
|
+
return !!descriptor && "value" in descriptor && descriptor.value === expected;
|
|
621
|
+
}
|
|
622
|
+
function inheritedMethod(object, name, expected, primitiveConstructor) {
|
|
623
|
+
if (Object.prototype.hasOwnProperty.call(object, name))
|
|
624
|
+
return false;
|
|
625
|
+
const prototype = Object.getPrototypeOf(object);
|
|
626
|
+
const originalPrimitiveValuePrototype = Object.getPrototypeOf(primitiveConstructor.prototype);
|
|
627
|
+
if (prototype !== primitiveConstructor.prototype ||
|
|
628
|
+
Object.getPrototypeOf(prototype) !== originalPrimitiveValuePrototype) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
const descriptor = prototype && Object.getOwnPropertyDescriptor(prototype, name);
|
|
632
|
+
if (descriptor)
|
|
633
|
+
return false;
|
|
634
|
+
const parentDescriptor = Object.getOwnPropertyDescriptor(originalPrimitiveValuePrototype, name);
|
|
635
|
+
return !!parentDescriptor && "value" in parentDescriptor && parentDescriptor.value === expected;
|
|
636
|
+
}
|
|
637
|
+
function plainPayload(value, allowEmpty = false) {
|
|
638
|
+
if (!(value instanceof Uint8Array) || Object.getPrototypeOf(value) !== Uint8Array.prototype)
|
|
639
|
+
return undefined;
|
|
640
|
+
for (const name of ["buffer", "byteOffset", "byteLength", "length", "slice", "constructor"]) {
|
|
641
|
+
if (Object.prototype.hasOwnProperty.call(value, name))
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
const constructorDescriptor = Object.getOwnPropertyDescriptor(Uint8Array.prototype, "constructor");
|
|
645
|
+
if (!constructorDescriptor ||
|
|
646
|
+
!("value" in constructorDescriptor) ||
|
|
647
|
+
constructorDescriptor.value !== originalUint8ArrayConstructor)
|
|
648
|
+
return undefined;
|
|
649
|
+
if (!stableInheritedMethod(Uint8Array.prototype, "slice", originalUint8ArraySliceInfo))
|
|
650
|
+
return undefined;
|
|
651
|
+
try {
|
|
652
|
+
const buffer = value.buffer;
|
|
653
|
+
if (!(buffer instanceof ArrayBuffer) || Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype)
|
|
654
|
+
return undefined;
|
|
655
|
+
if (Object.prototype.hasOwnProperty.call(buffer, "byteLength"))
|
|
656
|
+
return undefined;
|
|
657
|
+
if (value.byteLength !== value.length || (!allowEmpty && value.byteLength === 0))
|
|
658
|
+
return undefined;
|
|
659
|
+
if (value.byteOffset < 0 || value.byteOffset + value.byteLength > buffer.byteLength)
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
catch {
|
|
663
|
+
return undefined;
|
|
664
|
+
}
|
|
665
|
+
return value;
|
|
666
|
+
}
|
|
667
|
+
function validIdBlock(block, constructed, registry) {
|
|
668
|
+
if (Object.getPrototypeOf(block) !== registry.LocalIdentificationBlock.prototype)
|
|
669
|
+
return false;
|
|
670
|
+
if (!prototypeMethod(block, registry.LocalIdentificationBlock.prototype, "toBER", registry.originalIdentificationToBER))
|
|
671
|
+
return false;
|
|
672
|
+
const tagClass = dataProperty(block, "tagClass");
|
|
673
|
+
const tagNumber = dataProperty(block, "tagNumber");
|
|
674
|
+
const isConstructed = dataProperty(block, "isConstructed");
|
|
675
|
+
const isHexOnly = dataProperty(block, "isHexOnly");
|
|
676
|
+
const valueHexView = dataProperty(block, "valueHexView");
|
|
677
|
+
if (typeof tagClass !== "number" || !Number.isInteger(tagClass) || tagClass < 1 || tagClass > 4)
|
|
678
|
+
return false;
|
|
679
|
+
if (typeof tagNumber !== "number" || !Number.isInteger(tagNumber) || tagNumber < 0)
|
|
680
|
+
return false;
|
|
681
|
+
if (isConstructed !== constructed || typeof isHexOnly !== "boolean")
|
|
682
|
+
return false;
|
|
683
|
+
if (isHexOnly)
|
|
684
|
+
return !!plainPayload(valueHexView);
|
|
685
|
+
return Number.isSafeInteger(tagNumber);
|
|
686
|
+
}
|
|
687
|
+
function validLengthBlock(block, allowIndefinite, registry) {
|
|
688
|
+
if (Object.getPrototypeOf(block) !== registry.LocalLengthBlock.prototype)
|
|
689
|
+
return false;
|
|
690
|
+
if (!prototypeMethod(block, registry.LocalLengthBlock.prototype, "toBER", registry.originalLengthToBER))
|
|
691
|
+
return false;
|
|
692
|
+
const indefinite = dataProperty(block, "isIndefiniteForm");
|
|
693
|
+
const longForm = dataProperty(block, "longFormUsed");
|
|
694
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(block, "length");
|
|
695
|
+
const length = lengthDescriptor && "value" in lengthDescriptor ? lengthDescriptor.value : undefined;
|
|
696
|
+
const longFormDescriptor = Object.getOwnPropertyDescriptor(block, "longFormUsed");
|
|
697
|
+
return (typeof indefinite === "boolean" &&
|
|
698
|
+
(indefinite === false || allowIndefinite) &&
|
|
699
|
+
typeof longForm === "boolean" &&
|
|
700
|
+
!!longFormDescriptor &&
|
|
701
|
+
"value" in longFormDescriptor &&
|
|
702
|
+
longFormDescriptor.writable === true &&
|
|
703
|
+
!!lengthDescriptor &&
|
|
704
|
+
"value" in lengthDescriptor &&
|
|
705
|
+
lengthDescriptor.writable === true &&
|
|
706
|
+
typeof length === "number" &&
|
|
707
|
+
Number.isSafeInteger(length) &&
|
|
708
|
+
length >= 0);
|
|
709
|
+
}
|
|
710
|
+
function validBaseBlock(block, isConstructed, registry) {
|
|
711
|
+
const idBlock = dataProperty(block, "idBlock");
|
|
712
|
+
const lenBlock = dataProperty(block, "lenBlock");
|
|
713
|
+
return (!!idBlock &&
|
|
714
|
+
!!lenBlock &&
|
|
715
|
+
validIdBlock(idBlock, isConstructed, registry) &&
|
|
716
|
+
validLengthBlock(lenBlock, isConstructed, registry));
|
|
717
|
+
}
|
|
718
|
+
function constructedChild(block, registry) {
|
|
719
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
720
|
+
if (!valueBlock || Object.getPrototypeOf(valueBlock) !== registry.LocalConstructedValueBlock.prototype)
|
|
721
|
+
return undefined;
|
|
722
|
+
if (!prototypeMethod(valueBlock, registry.LocalConstructedValueBlock.prototype, "toBER", registry.originalConstructedToBER))
|
|
723
|
+
return undefined;
|
|
724
|
+
const values = dataProperty(valueBlock, "value");
|
|
725
|
+
if (!Array.isArray(values) || Object.getPrototypeOf(values) !== Array.prototype)
|
|
726
|
+
return undefined;
|
|
727
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(values, "length");
|
|
728
|
+
if (!lengthDescriptor || !("value" in lengthDescriptor) || lengthDescriptor.value !== 1)
|
|
729
|
+
return undefined;
|
|
730
|
+
if (Object.prototype.hasOwnProperty.call(values, Symbol.iterator))
|
|
731
|
+
return undefined;
|
|
732
|
+
const iteratorDescriptor = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator);
|
|
733
|
+
if (!iteratorDescriptor || !("value" in iteratorDescriptor) || iteratorDescriptor.value !== originalArrayIterator)
|
|
734
|
+
return undefined;
|
|
735
|
+
const indexDescriptor = Object.getOwnPropertyDescriptor(values, "0");
|
|
736
|
+
if (!indexDescriptor || !("value" in indexDescriptor))
|
|
737
|
+
return undefined;
|
|
738
|
+
if (Object.getOwnPropertyNames(values).length !== 2)
|
|
739
|
+
return undefined;
|
|
740
|
+
return indexDescriptor.value;
|
|
741
|
+
}
|
|
742
|
+
function bitPayload(block, registry) {
|
|
743
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
744
|
+
if (!valueBlock || Object.getPrototypeOf(valueBlock) !== registry.LocalBitStringValueBlock.prototype)
|
|
745
|
+
return undefined;
|
|
746
|
+
if (!prototypeMethod(valueBlock, registry.LocalBitStringValueBlock.prototype, "toBER", registry.originalBitStringToBER))
|
|
747
|
+
return undefined;
|
|
748
|
+
if (dataProperty(valueBlock, "isConstructed") !== false)
|
|
749
|
+
return undefined;
|
|
750
|
+
const unusedBits = dataProperty(valueBlock, "unusedBits");
|
|
751
|
+
if (typeof unusedBits !== "number" || !Number.isInteger(unusedBits) || unusedBits < 0 || unusedBits > 7)
|
|
752
|
+
return undefined;
|
|
753
|
+
const payload = plainPayload(dataProperty(valueBlock, "valueHexView"), true);
|
|
754
|
+
if (!payload)
|
|
755
|
+
return undefined;
|
|
756
|
+
return { payload, prefix: Uint8Array.of(payload.byteLength ? unusedBits : 0) };
|
|
757
|
+
}
|
|
758
|
+
function primitivePayload(block, kind, registry) {
|
|
759
|
+
const valueBlock = dataProperty(block, "valueBlock");
|
|
760
|
+
if (!valueBlock)
|
|
761
|
+
return undefined;
|
|
762
|
+
if (kind === "integer") {
|
|
763
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalIntegerValueBlock.prototype)
|
|
764
|
+
return undefined;
|
|
765
|
+
if (!prototypeMethod(valueBlock, registry.LocalIntegerValueBlock.prototype, "toBER", registry.originalIntegerToBER))
|
|
766
|
+
return undefined;
|
|
767
|
+
}
|
|
768
|
+
else if (kind === "octet") {
|
|
769
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalOctetStringValueBlock.prototype)
|
|
770
|
+
return undefined;
|
|
771
|
+
if (!prototypeMethod(valueBlock, registry.LocalOctetStringValueBlock.prototype, "toBER", registry.originalOctetStringToBER))
|
|
772
|
+
return undefined;
|
|
773
|
+
if (dataProperty(valueBlock, "isConstructed") !== false)
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
if (Object.getPrototypeOf(valueBlock) !== registry.LocalPrimitiveValueBlock.prototype)
|
|
778
|
+
return undefined;
|
|
779
|
+
if (!inheritedMethod(valueBlock, "toBER", registry.originalPrimitiveToBER, registry.LocalPrimitiveValueBlock))
|
|
780
|
+
return undefined;
|
|
781
|
+
}
|
|
782
|
+
if (kind === "primitive" && dataProperty(valueBlock, "isHexOnly") !== true)
|
|
783
|
+
return undefined;
|
|
784
|
+
if (typeof dataProperty(valueBlock, "isHexOnly") !== "boolean")
|
|
785
|
+
return undefined;
|
|
786
|
+
return plainPayload(dataProperty(valueBlock, "valueHexView"));
|
|
787
|
+
}
|
|
788
|
+
function validOuterMethod(block, registry) {
|
|
789
|
+
if (Object.prototype.hasOwnProperty.call(block, "toBER"))
|
|
790
|
+
return false;
|
|
791
|
+
let prototype = block;
|
|
792
|
+
while (prototype) {
|
|
793
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, "toBER");
|
|
794
|
+
if (descriptor)
|
|
795
|
+
return "value" in descriptor && descriptor.value === registry.originalBaseBlockToBER;
|
|
796
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
797
|
+
}
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
function isPrimitive(block, type, registry) {
|
|
801
|
+
const constructor = registry[type];
|
|
802
|
+
return !!constructor && Object.getPrototypeOf(block) === constructor.prototype;
|
|
803
|
+
}
|
|
804
|
+
function isConstructed(block, registry) {
|
|
805
|
+
return (Object.getPrototypeOf(block) === registry.Sequence.prototype ||
|
|
806
|
+
Object.getPrototypeOf(block) === registry.Set.prototype ||
|
|
807
|
+
Object.getPrototypeOf(block) === registry.Constructed.prototype);
|
|
808
|
+
}
|
|
809
|
+
function inspectNode(block, depth, registry) {
|
|
810
|
+
if (depth > BUILTIN_DISPATCH_MAX_DEPTH || !block || typeof block !== "object")
|
|
811
|
+
return undefined;
|
|
812
|
+
try {
|
|
813
|
+
if (!validOuterMethod(block, registry))
|
|
814
|
+
return undefined;
|
|
815
|
+
const primitiveKind = isPrimitive(block, "BitString", registry)
|
|
816
|
+
? "bit"
|
|
817
|
+
: isPrimitive(block, "Integer", registry)
|
|
818
|
+
? "integer"
|
|
819
|
+
: isPrimitive(block, "OctetString", registry)
|
|
820
|
+
? "octet"
|
|
821
|
+
: isPrimitive(block, "Primitive", registry)
|
|
822
|
+
? "primitive"
|
|
823
|
+
: undefined;
|
|
824
|
+
const constructed = primitiveKind === undefined && isConstructed(block, registry);
|
|
825
|
+
if (!primitiveKind && !constructed)
|
|
826
|
+
return undefined;
|
|
827
|
+
if (!validBaseBlock(block, constructed, registry))
|
|
828
|
+
return undefined;
|
|
829
|
+
const idBlock = dataProperty(block, "idBlock");
|
|
830
|
+
const lenBlock = dataProperty(block, "lenBlock");
|
|
831
|
+
if (!idBlock || !lenBlock)
|
|
832
|
+
return undefined;
|
|
833
|
+
if (primitiveKind) {
|
|
834
|
+
const bit = primitiveKind === "bit" ? bitPayload(block, registry) : undefined;
|
|
835
|
+
const payload = primitiveKind === "bit" ? bit === null || bit === void 0 ? void 0 : bit.payload : primitivePayload(block, primitiveKind, registry);
|
|
836
|
+
return payload
|
|
837
|
+
? { block, kind: primitiveKind, idBlock, lenBlock, indefinite: false, payload, prefix: bit === null || bit === void 0 ? void 0 : bit.prefix }
|
|
838
|
+
: undefined;
|
|
839
|
+
}
|
|
840
|
+
const child = constructedChild(block, registry);
|
|
841
|
+
const validatedChild = child && inspectNode(child, depth + 1, registry);
|
|
842
|
+
const indefinite = dataProperty(lenBlock, "isIndefiniteForm");
|
|
843
|
+
return validatedChild
|
|
844
|
+
? { block, kind: "constructed", idBlock, lenBlock, indefinite: indefinite === true, child: validatedChild }
|
|
845
|
+
: undefined;
|
|
846
|
+
}
|
|
847
|
+
catch {
|
|
848
|
+
return undefined;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function buildNode(node, sizeOnly, registry) {
|
|
852
|
+
var _a, _b;
|
|
853
|
+
const id = Reflect.apply(registry.originalIdentificationToBER, node.idBlock, [sizeOnly]);
|
|
854
|
+
if (!(id instanceof ArrayBuffer) || id.byteLength === 0)
|
|
855
|
+
throw TypeError("Built-in identifier encoding failed");
|
|
856
|
+
let payload;
|
|
857
|
+
if (node.kind === "constructed") {
|
|
858
|
+
payload = buildNode(node.child, sizeOnly, registry);
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
payload = node.payload;
|
|
862
|
+
}
|
|
863
|
+
const length = (payload instanceof Uint8Array ? payload.byteLength : payload.total) + ((_b = (_a = node.prefix) === null || _a === void 0 ? void 0 : _a.byteLength) !== null && _b !== void 0 ? _b : 0);
|
|
864
|
+
let len;
|
|
865
|
+
if (node.indefinite) {
|
|
866
|
+
len = Uint8Array.of(0x80).buffer;
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
node.lenBlock.length = length;
|
|
870
|
+
len = Reflect.apply(registry.originalLengthToBER, node.lenBlock, [sizeOnly]);
|
|
871
|
+
if (!(len instanceof ArrayBuffer) || len.byteLength === 0)
|
|
872
|
+
throw TypeError("Built-in length encoding failed");
|
|
873
|
+
}
|
|
874
|
+
const total = id.byteLength + len.byteLength + length + (node.indefinite ? 2 : 0);
|
|
875
|
+
if (!Number.isSafeInteger(total))
|
|
876
|
+
throw RangeError("Built-in encoding is too large");
|
|
877
|
+
return { id, len, payload, length, total, indefinite: node.indefinite, prefix: node.prefix };
|
|
878
|
+
}
|
|
879
|
+
function flatten(node, output, offset, sizeOnly) {
|
|
880
|
+
output.set(new Uint8Array(node.id), offset);
|
|
881
|
+
offset += node.id.byteLength;
|
|
882
|
+
output.set(new Uint8Array(node.len), offset);
|
|
883
|
+
offset += node.len.byteLength;
|
|
884
|
+
if (node.prefix) {
|
|
885
|
+
if (!sizeOnly)
|
|
886
|
+
output.set(node.prefix, offset);
|
|
887
|
+
offset += node.prefix.byteLength;
|
|
888
|
+
}
|
|
889
|
+
if (node.payload instanceof Uint8Array) {
|
|
890
|
+
if (!sizeOnly)
|
|
891
|
+
output.set(node.payload, offset);
|
|
892
|
+
offset += node.payload.byteLength;
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
offset = flatten(node.payload, output, offset, sizeOnly);
|
|
896
|
+
}
|
|
897
|
+
if (node.indefinite)
|
|
898
|
+
offset += 2;
|
|
899
|
+
return offset;
|
|
900
|
+
}
|
|
901
|
+
function tryEncodeBuiltin(block, sizeOnly = false) {
|
|
902
|
+
const registry = builtinRegistry;
|
|
903
|
+
if (!registry || !writerMethodsStable(registry))
|
|
904
|
+
return undefined;
|
|
905
|
+
const validated = inspectNode(block, 0, registry);
|
|
906
|
+
if (!validated)
|
|
907
|
+
return undefined;
|
|
908
|
+
const node = buildNode(validated, sizeOnly, registry);
|
|
909
|
+
const output = new Uint8Array(node.total);
|
|
910
|
+
flatten(node, output, 0, sizeOnly);
|
|
911
|
+
return output.buffer;
|
|
912
|
+
}
|
|
913
|
+
|
|
492
914
|
class BaseBlock extends LocalBaseBlock {
|
|
493
915
|
constructor({ name = EMPTY_STRING, optional = false, primitiveSchema, ...parameters } = {}, valueBlockType) {
|
|
494
916
|
super(parameters);
|
|
@@ -502,9 +924,7 @@ class BaseBlock extends LocalBaseBlock {
|
|
|
502
924
|
this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters);
|
|
503
925
|
}
|
|
504
926
|
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
505
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset,
|
|
506
|
-
? inputLength
|
|
507
|
-
: this.lenBlock.length, context);
|
|
927
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
508
928
|
if (resultOffset === -1) {
|
|
509
929
|
this.error = this.valueBlock.error;
|
|
510
930
|
return resultOffset;
|
|
@@ -521,6 +941,13 @@ class BaseBlock extends LocalBaseBlock {
|
|
|
521
941
|
const _writer = writer || new ViewWriter();
|
|
522
942
|
if (!writer) {
|
|
523
943
|
prepareIndefiniteForm(this);
|
|
944
|
+
if (sizeOnly === true || sizeOnly === false || sizeOnly === undefined) {
|
|
945
|
+
if (shouldUseBuiltinEncoder(this)) {
|
|
946
|
+
const encoded = tryEncodeBuiltin(this, sizeOnly === true);
|
|
947
|
+
if (encoded)
|
|
948
|
+
return encoded;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
524
951
|
}
|
|
525
952
|
const idBlockBuf = this.idBlock.toBER(sizeOnly);
|
|
526
953
|
_writer.write(idBlockBuf);
|
|
@@ -548,7 +975,7 @@ class BaseBlock extends LocalBaseBlock {
|
|
|
548
975
|
lenBlock: this.lenBlock.toJSON(),
|
|
549
976
|
valueBlock: this.valueBlock.toJSON(),
|
|
550
977
|
name: this.name,
|
|
551
|
-
optional: this.optional
|
|
978
|
+
optional: this.optional
|
|
552
979
|
};
|
|
553
980
|
if (this.primitiveSchema)
|
|
554
981
|
object.primitiveSchema = this.primitiveSchema.toJSON();
|
|
@@ -578,6 +1005,7 @@ class BaseBlock extends LocalBaseBlock {
|
|
|
578
1005
|
}
|
|
579
1006
|
}
|
|
580
1007
|
BaseBlock.NAME = "BaseBlock";
|
|
1008
|
+
const ORIGINAL_BASE_BLOCK_TO_BER = BaseBlock.prototype.toBER;
|
|
581
1009
|
function prepareIndefiniteForm(baseBlock) {
|
|
582
1010
|
var _a;
|
|
583
1011
|
if (baseBlock instanceof typeStore.Constructed) {
|
|
@@ -604,9 +1032,7 @@ class BaseStringBlock extends BaseBlock {
|
|
|
604
1032
|
}
|
|
605
1033
|
}
|
|
606
1034
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
607
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset,
|
|
608
|
-
? inputLength
|
|
609
|
-
: this.lenBlock.length);
|
|
1035
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length);
|
|
610
1036
|
if (resultOffset === -1) {
|
|
611
1037
|
this.error = this.valueBlock.error;
|
|
612
1038
|
return resultOffset;
|
|
@@ -626,6 +1052,7 @@ class BaseStringBlock extends BaseBlock {
|
|
|
626
1052
|
}
|
|
627
1053
|
BaseStringBlock.NAME = "BaseStringBlock";
|
|
628
1054
|
|
|
1055
|
+
var _a$x;
|
|
629
1056
|
class LocalPrimitiveValueBlock extends HexBlock(ValueBlock) {
|
|
630
1057
|
constructor({ isHexOnly = true, ...parameters } = {}) {
|
|
631
1058
|
super(parameters);
|
|
@@ -633,6 +1060,7 @@ class LocalPrimitiveValueBlock extends HexBlock(ValueBlock) {
|
|
|
633
1060
|
}
|
|
634
1061
|
}
|
|
635
1062
|
LocalPrimitiveValueBlock.NAME = "PrimitiveValueBlock";
|
|
1063
|
+
const ORIGINAL_LOCAL_PRIMITIVE_TO_BER = (_a$x = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(LocalPrimitiveValueBlock.prototype), "toBER")) === null || _a$x === void 0 ? void 0 : _a$x.value;
|
|
636
1064
|
|
|
637
1065
|
var _a$w;
|
|
638
1066
|
class Primitive extends BaseBlock {
|
|
@@ -647,6 +1075,101 @@ _a$w = Primitive;
|
|
|
647
1075
|
})();
|
|
648
1076
|
Primitive.NAME = "PRIMITIVE";
|
|
649
1077
|
|
|
1078
|
+
let fastParserRegistry;
|
|
1079
|
+
function registerFastParser(constructors) {
|
|
1080
|
+
fastParserRegistry = {
|
|
1081
|
+
Integer: constructors.Integer,
|
|
1082
|
+
Null: constructors.Null,
|
|
1083
|
+
Sequence: constructors.Sequence
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
function fastParserContext(context) {
|
|
1087
|
+
const nodes = Object.getOwnPropertyDescriptor(context, "nodesCount");
|
|
1088
|
+
const maxNodes = Object.getOwnPropertyDescriptor(context, "maxNodes");
|
|
1089
|
+
const maxContentLength = Object.getOwnPropertyDescriptor(context, "maxContentLength");
|
|
1090
|
+
if (!nodes || !("value" in nodes) || nodes.writable !== true)
|
|
1091
|
+
return false;
|
|
1092
|
+
if (!maxNodes || !("value" in maxNodes) || !maxContentLength || !("value" in maxContentLength))
|
|
1093
|
+
return false;
|
|
1094
|
+
return (typeof nodes.value === "number" &&
|
|
1095
|
+
Number.isSafeInteger(nodes.value) &&
|
|
1096
|
+
nodes.value >= 0 &&
|
|
1097
|
+
typeof maxNodes.value === "number" &&
|
|
1098
|
+
Number.isSafeInteger(maxNodes.value) &&
|
|
1099
|
+
maxNodes.value >= 0 &&
|
|
1100
|
+
typeof maxContentLength.value === "number" &&
|
|
1101
|
+
Number.isSafeInteger(maxContentLength.value) &&
|
|
1102
|
+
maxContentLength.value >= 0 &&
|
|
1103
|
+
nodes.value < maxNodes.value);
|
|
1104
|
+
}
|
|
1105
|
+
function fastParserType(store, name, value) {
|
|
1106
|
+
const descriptor = Object.getOwnPropertyDescriptor(store, name);
|
|
1107
|
+
return !!descriptor && "value" in descriptor && descriptor.value === value;
|
|
1108
|
+
}
|
|
1109
|
+
function tryFastFromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
1110
|
+
const registry = fastParserRegistry;
|
|
1111
|
+
if (!registry)
|
|
1112
|
+
return undefined;
|
|
1113
|
+
let Constructor;
|
|
1114
|
+
let length = 0;
|
|
1115
|
+
try {
|
|
1116
|
+
if (Object.getPrototypeOf(inputBuffer) !== Uint8Array.prototype)
|
|
1117
|
+
return undefined;
|
|
1118
|
+
if (!Number.isSafeInteger(inputOffset) ||
|
|
1119
|
+
inputOffset < 0 ||
|
|
1120
|
+
!Number.isSafeInteger(inputLength) ||
|
|
1121
|
+
inputLength < 2) {
|
|
1122
|
+
return undefined;
|
|
1123
|
+
}
|
|
1124
|
+
if (inputOffset > inputBuffer.byteLength || inputLength > inputBuffer.byteLength - inputOffset)
|
|
1125
|
+
return undefined;
|
|
1126
|
+
const tag = inputBuffer[inputOffset];
|
|
1127
|
+
if (tag !== 0x02 && tag !== 0x05 && tag !== 0x30)
|
|
1128
|
+
return undefined;
|
|
1129
|
+
length = inputBuffer[inputOffset + 1];
|
|
1130
|
+
if (length >= 0x80 || length > inputLength - 2)
|
|
1131
|
+
return undefined;
|
|
1132
|
+
if (tag === 0x05 && length !== 0)
|
|
1133
|
+
return undefined;
|
|
1134
|
+
if (!fastParserContext(context))
|
|
1135
|
+
return undefined;
|
|
1136
|
+
if (length > Object.getOwnPropertyDescriptor(context, "maxContentLength").value) {
|
|
1137
|
+
return undefined;
|
|
1138
|
+
}
|
|
1139
|
+
const constructorName = tag === 0x02 ? "Integer" : tag === 0x05 ? "Null" : "Sequence";
|
|
1140
|
+
Constructor = registry[constructorName];
|
|
1141
|
+
if (!fastParserType(typeStore, constructorName, Constructor))
|
|
1142
|
+
return undefined;
|
|
1143
|
+
const identificationFromBER = Object.getOwnPropertyDescriptor(LocalIdentificationBlock.prototype, "fromBER");
|
|
1144
|
+
const lengthFromBER = Object.getOwnPropertyDescriptor(LocalLengthBlock.prototype, "fromBER");
|
|
1145
|
+
if (!identificationFromBER ||
|
|
1146
|
+
!("value" in identificationFromBER) ||
|
|
1147
|
+
identificationFromBER.value !== ORIGINAL_LOCAL_IDENTIFICATION_FROM_BER ||
|
|
1148
|
+
!lengthFromBER ||
|
|
1149
|
+
!("value" in lengthFromBER) ||
|
|
1150
|
+
lengthFromBER.value !== ORIGINAL_LOCAL_LENGTH_FROM_BER)
|
|
1151
|
+
return undefined;
|
|
1152
|
+
}
|
|
1153
|
+
catch {
|
|
1154
|
+
return undefined;
|
|
1155
|
+
}
|
|
1156
|
+
if (!Constructor)
|
|
1157
|
+
return undefined;
|
|
1158
|
+
const result = new Constructor();
|
|
1159
|
+
result.idBlock.tagClass = 1;
|
|
1160
|
+
result.idBlock.tagNumber = inputBuffer[inputOffset] & 0x1f;
|
|
1161
|
+
result.idBlock.isConstructed = inputBuffer[inputOffset] === 0x30;
|
|
1162
|
+
result.idBlock.isHexOnly = false;
|
|
1163
|
+
result.idBlock.blockLength = 1;
|
|
1164
|
+
result.lenBlock.isIndefiniteForm = false;
|
|
1165
|
+
result.lenBlock.longFormUsed = false;
|
|
1166
|
+
result.lenBlock.length = length;
|
|
1167
|
+
result.lenBlock.blockLength = 1;
|
|
1168
|
+
context.nodesCount += 1;
|
|
1169
|
+
const resultOffset = result.fromBER(inputBuffer, inputOffset + 2, length, context);
|
|
1170
|
+
result.valueBeforeDecodeView = inputBuffer.subarray(inputOffset, inputOffset + result.blockLength);
|
|
1171
|
+
return { offset: resultOffset, result };
|
|
1172
|
+
}
|
|
650
1173
|
const DEFAULT_MAX_DEPTH = 100;
|
|
651
1174
|
const DEFAULT_MAX_NODES = 10000;
|
|
652
1175
|
const DEFAULT_MAX_CONTENT_LENGTH = 16 * 1024 * 1024;
|
|
@@ -654,13 +1177,14 @@ const MAX_DEPTH_EXCEEDED_ERROR = "Maximum ASN.1 nesting depth exceeded";
|
|
|
654
1177
|
const MAX_NODES_EXCEEDED_ERROR = "Maximum ASN.1 node count exceeded";
|
|
655
1178
|
const MAX_CONTENT_LENGTH_EXCEEDED_ERROR = "Maximum ASN.1 content length exceeded";
|
|
656
1179
|
function createFromBerContext(options = {}) {
|
|
657
|
-
var _a, _b, _c;
|
|
1180
|
+
var _a, _b, _c, _d;
|
|
658
1181
|
return {
|
|
659
1182
|
depth: 0,
|
|
660
1183
|
maxDepth: (_a = options.maxDepth) !== null && _a !== void 0 ? _a : DEFAULT_MAX_DEPTH,
|
|
661
1184
|
nodesCount: 0,
|
|
662
1185
|
maxNodes: (_b = options.maxNodes) !== null && _b !== void 0 ? _b : DEFAULT_MAX_NODES,
|
|
663
1186
|
maxContentLength: (_c = options.maxContentLength) !== null && _c !== void 0 ? _c : DEFAULT_MAX_CONTENT_LENGTH,
|
|
1187
|
+
parseEmbedded: (_d = options.parseEmbedded) !== null && _d !== void 0 ? _d : true
|
|
664
1188
|
};
|
|
665
1189
|
}
|
|
666
1190
|
function createErrorResult(error) {
|
|
@@ -668,7 +1192,7 @@ function createErrorResult(error) {
|
|
|
668
1192
|
result.error = error;
|
|
669
1193
|
return {
|
|
670
1194
|
offset: -1,
|
|
671
|
-
result
|
|
1195
|
+
result
|
|
672
1196
|
};
|
|
673
1197
|
}
|
|
674
1198
|
function checkNodesLimit(context) {
|
|
@@ -709,22 +1233,23 @@ function localChangeType(inputObject, newType) {
|
|
|
709
1233
|
return newObject;
|
|
710
1234
|
}
|
|
711
1235
|
function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length, context = createFromBerContext()) {
|
|
1236
|
+
const fastResult = tryFastFromBER(inputBuffer, inputOffset, inputLength, context);
|
|
1237
|
+
if (fastResult)
|
|
1238
|
+
return fastResult;
|
|
712
1239
|
const incomingOffset = inputOffset;
|
|
713
1240
|
let returnObject = new BaseBlock({}, ValueBlock);
|
|
714
|
-
|
|
715
|
-
if (!checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength)) {
|
|
716
|
-
returnObject.error = baseBlock.error;
|
|
1241
|
+
if (!checkBufferParams(returnObject, inputBuffer, inputOffset, inputLength)) {
|
|
717
1242
|
return {
|
|
718
1243
|
offset: -1,
|
|
719
|
-
result: returnObject
|
|
1244
|
+
result: returnObject
|
|
720
1245
|
};
|
|
721
1246
|
}
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
1247
|
+
const fastArgs = Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
1248
|
+
if (fastArgs ? inputLength === 0 : inputBuffer.subarray(inputOffset, inputOffset + inputLength).length === 0) {
|
|
724
1249
|
returnObject.error = "Zero buffer length";
|
|
725
1250
|
return {
|
|
726
1251
|
offset: -1,
|
|
727
|
-
result: returnObject
|
|
1252
|
+
result: returnObject
|
|
728
1253
|
};
|
|
729
1254
|
}
|
|
730
1255
|
const nodesLimitError = checkNodesLimit(context);
|
|
@@ -732,7 +1257,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
732
1257
|
returnObject.error = nodesLimitError;
|
|
733
1258
|
return {
|
|
734
1259
|
offset: -1,
|
|
735
|
-
result: returnObject
|
|
1260
|
+
result: returnObject
|
|
736
1261
|
};
|
|
737
1262
|
}
|
|
738
1263
|
let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength);
|
|
@@ -743,7 +1268,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
743
1268
|
returnObject.error = returnObject.idBlock.error;
|
|
744
1269
|
return {
|
|
745
1270
|
offset: -1,
|
|
746
|
-
result: returnObject
|
|
1271
|
+
result: returnObject
|
|
747
1272
|
};
|
|
748
1273
|
}
|
|
749
1274
|
inputOffset = resultOffset;
|
|
@@ -756,7 +1281,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
756
1281
|
returnObject.error = returnObject.lenBlock.error;
|
|
757
1282
|
return {
|
|
758
1283
|
offset: -1,
|
|
759
|
-
result: returnObject
|
|
1284
|
+
result: returnObject
|
|
760
1285
|
};
|
|
761
1286
|
}
|
|
762
1287
|
inputOffset = resultOffset;
|
|
@@ -767,36 +1292,33 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
767
1292
|
returnObject.error = contentLengthError;
|
|
768
1293
|
return {
|
|
769
1294
|
offset: -1,
|
|
770
|
-
result: returnObject
|
|
1295
|
+
result: returnObject
|
|
771
1296
|
};
|
|
772
1297
|
}
|
|
773
|
-
if (!returnObject.idBlock.isConstructed
|
|
774
|
-
&& returnObject.lenBlock.isIndefiniteForm) {
|
|
1298
|
+
if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) {
|
|
775
1299
|
returnObject.error = "Indefinite length form used for primitive encoding form";
|
|
776
1300
|
return {
|
|
777
1301
|
offset: -1,
|
|
778
|
-
result: returnObject
|
|
1302
|
+
result: returnObject
|
|
779
1303
|
};
|
|
780
1304
|
}
|
|
781
1305
|
let newASN1Type = BaseBlock;
|
|
782
1306
|
switch (returnObject.idBlock.tagClass) {
|
|
783
1307
|
case 1:
|
|
784
|
-
if (
|
|
785
|
-
&& (returnObject.idBlock.isHexOnly === false)) {
|
|
1308
|
+
if (returnObject.idBlock.tagNumber >= 37 && returnObject.idBlock.isHexOnly === false) {
|
|
786
1309
|
returnObject.error = "UNIVERSAL 37 and upper tags are reserved by ASN.1 standard";
|
|
787
1310
|
return {
|
|
788
1311
|
offset: -1,
|
|
789
|
-
result: returnObject
|
|
1312
|
+
result: returnObject
|
|
790
1313
|
};
|
|
791
1314
|
}
|
|
792
1315
|
switch (returnObject.idBlock.tagNumber) {
|
|
793
1316
|
case 0:
|
|
794
|
-
if (
|
|
795
|
-
&& (returnObject.lenBlock.length > 0)) {
|
|
1317
|
+
if (returnObject.idBlock.isConstructed && returnObject.lenBlock.length > 0) {
|
|
796
1318
|
returnObject.error = "Type [UNIVERSAL 0] is reserved";
|
|
797
1319
|
return {
|
|
798
1320
|
offset: -1,
|
|
799
|
-
result: returnObject
|
|
1321
|
+
result: returnObject
|
|
800
1322
|
};
|
|
801
1323
|
}
|
|
802
1324
|
newASN1Type = typeStore.EndOfContent;
|
|
@@ -835,7 +1357,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
835
1357
|
returnObject.error = "[UNIVERSAL 15] is reserved by ASN.1 standard";
|
|
836
1358
|
return {
|
|
837
1359
|
offset: -1,
|
|
838
|
-
result: returnObject
|
|
1360
|
+
result: returnObject
|
|
839
1361
|
};
|
|
840
1362
|
case 16:
|
|
841
1363
|
newASN1Type = typeStore.Sequence;
|
|
@@ -909,9 +1431,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
909
1431
|
case 3:
|
|
910
1432
|
case 4:
|
|
911
1433
|
default: {
|
|
912
|
-
newASN1Type = returnObject.idBlock.isConstructed
|
|
913
|
-
? typeStore.Constructed
|
|
914
|
-
: typeStore.Primitive;
|
|
1434
|
+
newASN1Type = returnObject.idBlock.isConstructed ? typeStore.Constructed : typeStore.Primitive;
|
|
915
1435
|
}
|
|
916
1436
|
}
|
|
917
1437
|
returnObject = localChangeType(returnObject, newASN1Type);
|
|
@@ -919,7 +1439,7 @@ function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.le
|
|
|
919
1439
|
returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength);
|
|
920
1440
|
return {
|
|
921
1441
|
offset: resultOffset,
|
|
922
|
-
result: returnObject
|
|
1442
|
+
result: returnObject
|
|
923
1443
|
};
|
|
924
1444
|
}
|
|
925
1445
|
function fromBER(inputBuffer, options = {}) {
|
|
@@ -928,10 +1448,12 @@ function fromBER(inputBuffer, options = {}) {
|
|
|
928
1448
|
result.error = "Input buffer has zero length";
|
|
929
1449
|
return {
|
|
930
1450
|
offset: -1,
|
|
931
|
-
result
|
|
1451
|
+
result
|
|
932
1452
|
};
|
|
933
1453
|
}
|
|
934
|
-
|
|
1454
|
+
const inputView = pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer);
|
|
1455
|
+
const normalizedInput = options.copyInput === false ? inputView : inputView.slice();
|
|
1456
|
+
return localFromBER(normalizedInput, 0, inputBuffer.byteLength, createFromBerContext(options));
|
|
935
1457
|
}
|
|
936
1458
|
|
|
937
1459
|
function checkLen(indefiniteLength, length) {
|
|
@@ -997,7 +1519,7 @@ class LocalConstructedValueBlock extends ValueBlock {
|
|
|
997
1519
|
const object = {
|
|
998
1520
|
...super.toJSON(),
|
|
999
1521
|
isIndefiniteForm: this.isIndefiniteForm,
|
|
1000
|
-
value: []
|
|
1522
|
+
value: []
|
|
1001
1523
|
};
|
|
1002
1524
|
for (const value of this.value) {
|
|
1003
1525
|
object.value.push(value.toJSON());
|
|
@@ -1006,6 +1528,7 @@ class LocalConstructedValueBlock extends ValueBlock {
|
|
|
1006
1528
|
}
|
|
1007
1529
|
}
|
|
1008
1530
|
LocalConstructedValueBlock.NAME = "ConstructedValueBlock";
|
|
1531
|
+
const ORIGINAL_LOCAL_CONSTRUCTED_TO_BER = LocalConstructedValueBlock.prototype.toBER;
|
|
1009
1532
|
|
|
1010
1533
|
var _a$v;
|
|
1011
1534
|
class Constructed extends BaseBlock {
|
|
@@ -1015,7 +1538,7 @@ class Constructed extends BaseBlock {
|
|
|
1015
1538
|
}
|
|
1016
1539
|
fromBER(inputBuffer, inputOffset, inputLength, context) {
|
|
1017
1540
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
1018
|
-
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset,
|
|
1541
|
+
const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length, context);
|
|
1019
1542
|
if (resultOffset === -1) {
|
|
1020
1543
|
this.error = this.valueBlock.error;
|
|
1021
1544
|
return resultOffset;
|
|
@@ -1031,11 +1554,13 @@ class Constructed extends BaseBlock {
|
|
|
1031
1554
|
onAsciiEncoding() {
|
|
1032
1555
|
const values = [];
|
|
1033
1556
|
for (const value of this.valueBlock.value) {
|
|
1034
|
-
values.push(value
|
|
1557
|
+
values.push(value
|
|
1558
|
+
.toString("ascii")
|
|
1559
|
+
.split("\n")
|
|
1560
|
+
.map(o => ` ${o}`)
|
|
1561
|
+
.join("\n"));
|
|
1035
1562
|
}
|
|
1036
|
-
const blockName = this.idBlock.tagClass === 3
|
|
1037
|
-
? `[${this.idBlock.tagNumber}]`
|
|
1038
|
-
: this.constructor.NAME;
|
|
1563
|
+
const blockName = this.idBlock.tagClass === 3 ? `[${this.idBlock.tagNumber}]` : this.constructor.NAME;
|
|
1039
1564
|
return values.length
|
|
1040
1565
|
? `${blockName} :\n${values.join("\n")}`
|
|
1041
1566
|
: `${blockName} :`;
|
|
@@ -1086,11 +1611,11 @@ class Null extends BaseBlock {
|
|
|
1086
1611
|
if (!this.lenBlock.error.length)
|
|
1087
1612
|
this.blockLength += this.lenBlock.blockLength;
|
|
1088
1613
|
this.blockLength += inputLength;
|
|
1089
|
-
if (
|
|
1614
|
+
if (inputOffset + inputLength > inputBuffer.byteLength) {
|
|
1090
1615
|
this.error = "End of input reached before message was fully decoded (inconsistent offset and length values)";
|
|
1091
1616
|
return -1;
|
|
1092
1617
|
}
|
|
1093
|
-
return
|
|
1618
|
+
return inputOffset + inputLength;
|
|
1094
1619
|
}
|
|
1095
1620
|
toBER(sizeOnly, writer) {
|
|
1096
1621
|
const retBuf = new ArrayBuffer(2);
|
|
@@ -1124,7 +1649,7 @@ class LocalBooleanValueBlock extends HexBlock(ValueBlock) {
|
|
|
1124
1649
|
return false;
|
|
1125
1650
|
}
|
|
1126
1651
|
set value(value) {
|
|
1127
|
-
this.valueHexView[0] = value ?
|
|
1652
|
+
this.valueHexView[0] = value ? 0xff : 0x00;
|
|
1128
1653
|
}
|
|
1129
1654
|
constructor({ value, ...parameters } = {}) {
|
|
1130
1655
|
super(parameters);
|
|
@@ -1149,15 +1674,15 @@ class LocalBooleanValueBlock extends HexBlock(ValueBlock) {
|
|
|
1149
1674
|
this.isHexOnly = true;
|
|
1150
1675
|
pvutils__namespace.utilDecodeTC.call(this);
|
|
1151
1676
|
this.blockLength = inputLength;
|
|
1152
|
-
return
|
|
1677
|
+
return inputOffset + inputLength;
|
|
1153
1678
|
}
|
|
1154
1679
|
toBER() {
|
|
1155
|
-
return this.valueHexView.slice();
|
|
1680
|
+
return this.valueHexView.slice().buffer;
|
|
1156
1681
|
}
|
|
1157
1682
|
toJSON() {
|
|
1158
1683
|
return {
|
|
1159
1684
|
...super.toJSON(),
|
|
1160
|
-
value: this.value
|
|
1685
|
+
value: this.value
|
|
1161
1686
|
};
|
|
1162
1687
|
}
|
|
1163
1688
|
}
|
|
@@ -1224,18 +1749,17 @@ class LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBlock) {
|
|
|
1224
1749
|
toBER(sizeOnly, writer) {
|
|
1225
1750
|
if (this.isConstructed)
|
|
1226
1751
|
return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer);
|
|
1227
|
-
return sizeOnly
|
|
1228
|
-
? new ArrayBuffer(this.valueHexView.byteLength)
|
|
1229
|
-
: this.valueHexView.slice().buffer;
|
|
1752
|
+
return sizeOnly ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
|
|
1230
1753
|
}
|
|
1231
1754
|
toJSON() {
|
|
1232
1755
|
return {
|
|
1233
1756
|
...super.toJSON(),
|
|
1234
|
-
isConstructed: this.isConstructed
|
|
1757
|
+
isConstructed: this.isConstructed
|
|
1235
1758
|
};
|
|
1236
1759
|
}
|
|
1237
1760
|
}
|
|
1238
1761
|
LocalOctetStringValueBlock.NAME = "OctetStringValueBlock";
|
|
1762
|
+
const ORIGINAL_LOCAL_OCTET_STRING_TO_BER = LocalOctetStringValueBlock.prototype.toBER;
|
|
1239
1763
|
|
|
1240
1764
|
var _a$r;
|
|
1241
1765
|
class OctetString extends BaseBlock {
|
|
@@ -1245,13 +1769,13 @@ class OctetString extends BaseBlock {
|
|
|
1245
1769
|
super({
|
|
1246
1770
|
idBlock: {
|
|
1247
1771
|
isConstructed: parameters.isConstructed,
|
|
1248
|
-
...idBlock
|
|
1772
|
+
...idBlock
|
|
1249
1773
|
},
|
|
1250
1774
|
lenBlock: {
|
|
1251
1775
|
...lenBlock,
|
|
1252
|
-
isIndefiniteForm: !!parameters.isIndefiniteForm
|
|
1776
|
+
isIndefiniteForm: !!parameters.isIndefiniteForm
|
|
1253
1777
|
},
|
|
1254
|
-
...parameters
|
|
1778
|
+
...parameters
|
|
1255
1779
|
}, LocalOctetStringValueBlock);
|
|
1256
1780
|
this.idBlock.tagClass = 1;
|
|
1257
1781
|
this.idBlock.tagNumber = 4;
|
|
@@ -1266,7 +1790,7 @@ class OctetString extends BaseBlock {
|
|
|
1266
1790
|
this.blockLength += this.lenBlock.blockLength;
|
|
1267
1791
|
return inputOffset;
|
|
1268
1792
|
}
|
|
1269
|
-
if (!this.valueBlock.isConstructed) {
|
|
1793
|
+
if (!this.valueBlock.isConstructed && (context === null || context === void 0 ? void 0 : context.parseEmbedded) !== false) {
|
|
1270
1794
|
const view = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer;
|
|
1271
1795
|
const buf = view.subarray(inputOffset, inputOffset + inputLength);
|
|
1272
1796
|
try {
|
|
@@ -1341,8 +1865,8 @@ class LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBlock) {
|
|
|
1341
1865
|
return -1;
|
|
1342
1866
|
}
|
|
1343
1867
|
const valueBlock = value.valueBlock;
|
|
1344
|
-
if (
|
|
1345
|
-
this.error =
|
|
1868
|
+
if (this.unusedBits > 0 && valueBlock.unusedBits > 0) {
|
|
1869
|
+
this.error = 'Using of "unused bits" inside constructive BIT STRING allowed for least one only';
|
|
1346
1870
|
return -1;
|
|
1347
1871
|
}
|
|
1348
1872
|
this.unusedBits = valueBlock.unusedBits;
|
|
@@ -1359,13 +1883,13 @@ class LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBlock) {
|
|
|
1359
1883
|
this.error = "Unused bits for BitString must be in range 0-7";
|
|
1360
1884
|
return -1;
|
|
1361
1885
|
}
|
|
1362
|
-
if (!this.unusedBits) {
|
|
1886
|
+
if (!this.unusedBits && (context === null || context === void 0 ? void 0 : context.parseEmbedded) !== false) {
|
|
1363
1887
|
const buf = intBuffer.subarray(1);
|
|
1364
1888
|
try {
|
|
1365
1889
|
if (buf.byteLength) {
|
|
1366
1890
|
const parseContext = context !== null && context !== void 0 ? context : createFromBerContext();
|
|
1367
1891
|
const asn = localFromBERWithChildContext(buf, 0, buf.byteLength, parseContext);
|
|
1368
|
-
if (asn.offset !== -1 && asn.offset ===
|
|
1892
|
+
if (asn.offset !== -1 && asn.offset === inputLength - 1) {
|
|
1369
1893
|
this.value = [asn.result];
|
|
1370
1894
|
}
|
|
1371
1895
|
}
|
|
@@ -1375,7 +1899,7 @@ class LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBlock) {
|
|
|
1375
1899
|
}
|
|
1376
1900
|
this.valueHexView = intBuffer.subarray(1);
|
|
1377
1901
|
this.blockLength = intBuffer.length;
|
|
1378
|
-
return
|
|
1902
|
+
return inputOffset + inputLength;
|
|
1379
1903
|
}
|
|
1380
1904
|
toBER(sizeOnly, writer) {
|
|
1381
1905
|
if (this.isConstructed) {
|
|
@@ -1398,11 +1922,12 @@ class LocalBitStringValueBlock extends HexBlock(LocalConstructedValueBlock) {
|
|
|
1398
1922
|
return {
|
|
1399
1923
|
...super.toJSON(),
|
|
1400
1924
|
unusedBits: this.unusedBits,
|
|
1401
|
-
isConstructed: this.isConstructed
|
|
1925
|
+
isConstructed: this.isConstructed
|
|
1402
1926
|
};
|
|
1403
1927
|
}
|
|
1404
1928
|
}
|
|
1405
1929
|
LocalBitStringValueBlock.NAME = "BitStringValueBlock";
|
|
1930
|
+
const ORIGINAL_LOCAL_BIT_STRING_TO_BER = LocalBitStringValueBlock.prototype.toBER;
|
|
1406
1931
|
|
|
1407
1932
|
var _a$q;
|
|
1408
1933
|
class BitString extends BaseBlock {
|
|
@@ -1412,13 +1937,13 @@ class BitString extends BaseBlock {
|
|
|
1412
1937
|
super({
|
|
1413
1938
|
idBlock: {
|
|
1414
1939
|
isConstructed: parameters.isConstructed,
|
|
1415
|
-
...idBlock
|
|
1940
|
+
...idBlock
|
|
1416
1941
|
},
|
|
1417
1942
|
lenBlock: {
|
|
1418
1943
|
...lenBlock,
|
|
1419
|
-
isIndefiniteForm: !!parameters.isIndefiniteForm
|
|
1944
|
+
isIndefiniteForm: !!parameters.isIndefiniteForm
|
|
1420
1945
|
},
|
|
1421
|
-
...parameters
|
|
1946
|
+
...parameters
|
|
1422
1947
|
}, LocalBitStringValueBlock);
|
|
1423
1948
|
this.idBlock.tagClass = 1;
|
|
1424
1949
|
this.idBlock.tagNumber = 3;
|
|
@@ -1451,94 +1976,53 @@ _a$q = BitString;
|
|
|
1451
1976
|
})();
|
|
1452
1977
|
BitString.NAME = BIT_STRING_NAME;
|
|
1453
1978
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
digits = pvutils__namespace.utilConcatView(c, digits);
|
|
1499
|
-
powers2.push(digits);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
return powers2[n];
|
|
1503
|
-
}
|
|
1504
|
-
function viewSub(first, second) {
|
|
1505
|
-
let b = 0;
|
|
1506
|
-
const firstView = new Uint8Array(first);
|
|
1507
|
-
const secondView = new Uint8Array(second);
|
|
1508
|
-
const firstViewCopy = firstView.slice(0);
|
|
1509
|
-
const firstViewCopyLength = firstViewCopy.length - 1;
|
|
1510
|
-
const secondViewCopy = secondView.slice(0);
|
|
1511
|
-
const secondViewCopyLength = secondViewCopy.length - 1;
|
|
1512
|
-
let value;
|
|
1513
|
-
let counter = 0;
|
|
1514
|
-
for (let i = secondViewCopyLength; i >= 0; i--, counter++) {
|
|
1515
|
-
value = firstViewCopy[firstViewCopyLength - counter] - secondViewCopy[secondViewCopyLength - counter] - b;
|
|
1516
|
-
switch (true) {
|
|
1517
|
-
case (value < 0):
|
|
1518
|
-
b = 1;
|
|
1519
|
-
firstViewCopy[firstViewCopyLength - counter] = value + 10;
|
|
1520
|
-
break;
|
|
1521
|
-
default:
|
|
1522
|
-
b = 0;
|
|
1523
|
-
firstViewCopy[firstViewCopyLength - counter] = value;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
if (b > 0) {
|
|
1527
|
-
for (let i = (firstViewCopyLength - secondViewCopyLength + 1); i >= 0; i--, counter++) {
|
|
1528
|
-
value = firstViewCopy[firstViewCopyLength - counter] - b;
|
|
1529
|
-
if (value < 0) {
|
|
1530
|
-
b = 1;
|
|
1531
|
-
firstViewCopy[firstViewCopyLength - counter] = value + 10;
|
|
1532
|
-
}
|
|
1533
|
-
else {
|
|
1534
|
-
b = 0;
|
|
1535
|
-
firstViewCopy[firstViewCopyLength - counter] = value;
|
|
1536
|
-
break;
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
return firstViewCopy.slice();
|
|
1979
|
+
function bytesToSignedBigInt(view) {
|
|
1980
|
+
if (!view.byteLength)
|
|
1981
|
+
return BigInt(0);
|
|
1982
|
+
const value = BigInt(`0x${pvtsutils__namespace.Convert.ToHex(view)}`);
|
|
1983
|
+
if (view[0] & 0x80)
|
|
1984
|
+
return value - (BigInt(1) << BigInt(view.byteLength * 8));
|
|
1985
|
+
return value;
|
|
1986
|
+
}
|
|
1987
|
+
function bytesToSignedDecimal(view) {
|
|
1988
|
+
if (typeof BigInt !== "undefined")
|
|
1989
|
+
return bytesToSignedBigInt(view).toString(10);
|
|
1990
|
+
const BASE = 10000000;
|
|
1991
|
+
const DECIMAL_DIGITS = 7;
|
|
1992
|
+
if (!view.byteLength)
|
|
1993
|
+
return "0";
|
|
1994
|
+
const negative = !!(view[0] & 0x80);
|
|
1995
|
+
let magnitude = view;
|
|
1996
|
+
if (negative) {
|
|
1997
|
+
magnitude = new Uint8Array(view.length);
|
|
1998
|
+
let carry = 1;
|
|
1999
|
+
for (let i = view.length - 1; i >= 0; i--) {
|
|
2000
|
+
const value = (view[i] ^ 0xff) + carry;
|
|
2001
|
+
magnitude[i] = value & 0xff;
|
|
2002
|
+
carry = value >> 8;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
const limbs = [0];
|
|
2006
|
+
for (let index = 0; index < magnitude.length; index++) {
|
|
2007
|
+
let carry = magnitude[index];
|
|
2008
|
+
for (let i = 0; i < limbs.length; i++) {
|
|
2009
|
+
const value = limbs[i] * 256 + carry;
|
|
2010
|
+
limbs[i] = value % BASE;
|
|
2011
|
+
carry = Math.floor(value / BASE);
|
|
2012
|
+
}
|
|
2013
|
+
if (carry)
|
|
2014
|
+
limbs.push(carry);
|
|
2015
|
+
}
|
|
2016
|
+
let top = limbs.length - 1;
|
|
2017
|
+
while (top > 0 && limbs[top] === 0)
|
|
2018
|
+
top--;
|
|
2019
|
+
let result = String(limbs[top]);
|
|
2020
|
+
for (let i = top - 1; i >= 0; i--)
|
|
2021
|
+
result += String(limbs[i]).padStart(DECIMAL_DIGITS, "0");
|
|
2022
|
+
return negative && result !== "0" ? `-${result}` : result;
|
|
1541
2023
|
}
|
|
2024
|
+
|
|
2025
|
+
var _a$p;
|
|
1542
2026
|
class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
|
|
1543
2027
|
setValueHex() {
|
|
1544
2028
|
if (this.valueHexView.length >= 4) {
|
|
@@ -1576,13 +2060,13 @@ class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
|
|
|
1576
2060
|
if (offset === -1)
|
|
1577
2061
|
return offset;
|
|
1578
2062
|
const view = this.valueHexView;
|
|
1579
|
-
if (
|
|
2063
|
+
if (view[0] === 0x00 && (view[1] & 0x80) !== 0) {
|
|
1580
2064
|
this.valueHexView = view.subarray(1);
|
|
1581
2065
|
}
|
|
1582
2066
|
else {
|
|
1583
2067
|
if (expectedLength !== 0) {
|
|
1584
2068
|
if (view.length < expectedLength) {
|
|
1585
|
-
if (
|
|
2069
|
+
if (expectedLength - view.length > 1)
|
|
1586
2070
|
expectedLength = view.length + 1;
|
|
1587
2071
|
this.valueHexView = view.subarray(expectedLength - view.length);
|
|
1588
2072
|
}
|
|
@@ -1593,7 +2077,7 @@ class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
|
|
|
1593
2077
|
toDER(sizeOnly = false) {
|
|
1594
2078
|
const view = this.valueHexView;
|
|
1595
2079
|
switch (true) {
|
|
1596
|
-
case (
|
|
2080
|
+
case (view[0] & 0x80) !== 0:
|
|
1597
2081
|
{
|
|
1598
2082
|
const updatedView = new Uint8Array(this.valueHexView.length + 1);
|
|
1599
2083
|
updatedView[0] = 0x00;
|
|
@@ -1601,7 +2085,7 @@ class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
|
|
|
1601
2085
|
this.valueHexView = updatedView;
|
|
1602
2086
|
}
|
|
1603
2087
|
break;
|
|
1604
|
-
case
|
|
2088
|
+
case view[0] === 0x00 && (view[1] & 0x80) === 0:
|
|
1605
2089
|
{
|
|
1606
2090
|
this.valueHexView = this.valueHexView.subarray(1);
|
|
1607
2091
|
}
|
|
@@ -1618,50 +2102,16 @@ class LocalIntegerValueBlock extends HexBlock(ValueBlock) {
|
|
|
1618
2102
|
return resultOffset;
|
|
1619
2103
|
}
|
|
1620
2104
|
toBER(sizeOnly) {
|
|
1621
|
-
return sizeOnly
|
|
1622
|
-
? new ArrayBuffer(this.valueHexView.length)
|
|
1623
|
-
: this.valueHexView.slice().buffer;
|
|
2105
|
+
return sizeOnly ? new ArrayBuffer(this.valueHexView.length) : this.valueHexView.slice().buffer;
|
|
1624
2106
|
}
|
|
1625
2107
|
toJSON() {
|
|
1626
2108
|
return {
|
|
1627
2109
|
...super.toJSON(),
|
|
1628
|
-
valueDec: this.valueDec
|
|
2110
|
+
valueDec: this.valueDec
|
|
1629
2111
|
};
|
|
1630
2112
|
}
|
|
1631
2113
|
toString() {
|
|
1632
|
-
|
|
1633
|
-
let digits = new Uint8Array((this.valueHexView.length * 8) / 3);
|
|
1634
|
-
let bitNumber = 0;
|
|
1635
|
-
let currentByte;
|
|
1636
|
-
const asn1View = this.valueHexView;
|
|
1637
|
-
let result = "";
|
|
1638
|
-
let flag = false;
|
|
1639
|
-
for (let byteNumber = (asn1View.byteLength - 1); byteNumber >= 0; byteNumber--) {
|
|
1640
|
-
currentByte = asn1View[byteNumber];
|
|
1641
|
-
for (let i = 0; i < 8; i++) {
|
|
1642
|
-
if ((currentByte & 1) === 1) {
|
|
1643
|
-
switch (bitNumber) {
|
|
1644
|
-
case firstBit:
|
|
1645
|
-
digits = viewSub(power2(bitNumber), digits);
|
|
1646
|
-
result = "-";
|
|
1647
|
-
break;
|
|
1648
|
-
default:
|
|
1649
|
-
digits = viewAdd(digits, power2(bitNumber));
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
bitNumber++;
|
|
1653
|
-
currentByte >>= 1;
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
for (let i = 0; i < digits.length; i++) {
|
|
1657
|
-
if (digits[i])
|
|
1658
|
-
flag = true;
|
|
1659
|
-
if (flag)
|
|
1660
|
-
result += digitsString.charAt(digits[i]);
|
|
1661
|
-
}
|
|
1662
|
-
if (flag === false)
|
|
1663
|
-
result += digitsString.charAt(0);
|
|
1664
|
-
return result;
|
|
2114
|
+
return bytesToSignedDecimal(this.valueHexView);
|
|
1665
2115
|
}
|
|
1666
2116
|
}
|
|
1667
2117
|
_a$p = LocalIntegerValueBlock;
|
|
@@ -1674,9 +2124,11 @@ LocalIntegerValueBlock.NAME = "IntegerValueBlock";
|
|
|
1674
2124
|
},
|
|
1675
2125
|
get: function () {
|
|
1676
2126
|
return this.valueHexView.slice().buffer;
|
|
1677
|
-
}
|
|
2127
|
+
}
|
|
1678
2128
|
});
|
|
1679
2129
|
})();
|
|
2130
|
+
const ORIGINAL_LOCAL_INTEGER_TO_BER = LocalIntegerValueBlock.prototype.toBER;
|
|
2131
|
+
const ORIGINAL_LOCAL_INTEGER_TO_STRING = LocalIntegerValueBlock.prototype.toString;
|
|
1680
2132
|
|
|
1681
2133
|
var _a$o;
|
|
1682
2134
|
class Integer extends BaseBlock {
|
|
@@ -1687,7 +2139,11 @@ class Integer extends BaseBlock {
|
|
|
1687
2139
|
}
|
|
1688
2140
|
toBigInt() {
|
|
1689
2141
|
assertBigInt();
|
|
1690
|
-
|
|
2142
|
+
const valueBlock = this.valueBlock;
|
|
2143
|
+
const toString = valueBlock.toString;
|
|
2144
|
+
if (toString === ORIGINAL_LOCAL_INTEGER_TO_STRING)
|
|
2145
|
+
return bytesToSignedBigInt(valueBlock.valueHexView);
|
|
2146
|
+
return BigInt(Reflect.apply(toString, valueBlock, []));
|
|
1691
2147
|
}
|
|
1692
2148
|
static fromBigInt(value) {
|
|
1693
2149
|
assertBigInt();
|
|
@@ -1720,9 +2176,7 @@ class Integer extends BaseBlock {
|
|
|
1720
2176
|
}
|
|
1721
2177
|
convertFromDER() {
|
|
1722
2178
|
return new _a$o({
|
|
1723
|
-
valueHex: this.valueBlock.valueHexView[0] === 0
|
|
1724
|
-
? this.valueBlock.valueHexView.subarray(1)
|
|
1725
|
-
: this.valueBlock.valueHexView,
|
|
2179
|
+
valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView
|
|
1726
2180
|
});
|
|
1727
2181
|
}
|
|
1728
2182
|
onAsciiEncoding() {
|
|
@@ -1764,18 +2218,34 @@ class LocalSidValueBlock extends HexBlock(ValueBlock) {
|
|
|
1764
2218
|
return -1;
|
|
1765
2219
|
}
|
|
1766
2220
|
const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
1767
|
-
this.
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
2221
|
+
const fastPath = this.blockLength === 0 && Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
2222
|
+
if (fastPath) {
|
|
2223
|
+
let sidLength = 0;
|
|
2224
|
+
while (sidLength < inputLength) {
|
|
2225
|
+
const octet = intBuffer[sidLength];
|
|
2226
|
+
sidLength++;
|
|
2227
|
+
if ((octet & 0x80) === 0x00)
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
this.blockLength = sidLength;
|
|
2231
|
+
this.valueHexView = new Uint8Array(sidLength);
|
|
2232
|
+
for (let i = 0; i < sidLength; i++)
|
|
2233
|
+
this.valueHexView[i] = intBuffer[i] & 0x7f;
|
|
1773
2234
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
2235
|
+
else {
|
|
2236
|
+
this.valueHexView = new Uint8Array(inputLength);
|
|
2237
|
+
for (let i = 0; i < inputLength; i++) {
|
|
2238
|
+
this.valueHexView[i] = intBuffer[i] & 0x7f;
|
|
2239
|
+
this.blockLength++;
|
|
2240
|
+
if ((intBuffer[i] & 0x80) === 0x00)
|
|
2241
|
+
break;
|
|
2242
|
+
}
|
|
2243
|
+
const tempView = new Uint8Array(this.blockLength);
|
|
2244
|
+
for (let i = 0; i < this.blockLength; i++) {
|
|
2245
|
+
tempView[i] = this.valueHexView[i];
|
|
2246
|
+
}
|
|
2247
|
+
this.valueHexView = tempView;
|
|
1777
2248
|
}
|
|
1778
|
-
this.valueHexView = tempView;
|
|
1779
2249
|
if ((intBuffer[this.blockLength - 1] & 0x80) !== 0x00) {
|
|
1780
2250
|
this.error = "End of input reached before message was fully decoded";
|
|
1781
2251
|
return -1;
|
|
@@ -1788,7 +2258,7 @@ class LocalSidValueBlock extends HexBlock(ValueBlock) {
|
|
|
1788
2258
|
this.isHexOnly = true;
|
|
1789
2259
|
this.warnings.push("Too big SID for decoding, hex only");
|
|
1790
2260
|
}
|
|
1791
|
-
return
|
|
2261
|
+
return inputOffset + this.blockLength;
|
|
1792
2262
|
}
|
|
1793
2263
|
set valueBigInt(value) {
|
|
1794
2264
|
assertBigInt();
|
|
@@ -1805,13 +2275,13 @@ class LocalSidValueBlock extends HexBlock(ValueBlock) {
|
|
|
1805
2275
|
toBER(sizeOnly) {
|
|
1806
2276
|
if (this.isHexOnly) {
|
|
1807
2277
|
if (sizeOnly)
|
|
1808
|
-
return
|
|
2278
|
+
return new ArrayBuffer(this.valueHexView.byteLength);
|
|
1809
2279
|
const curView = this.valueHexView;
|
|
1810
2280
|
const retView = new Uint8Array(this.blockLength);
|
|
1811
|
-
for (let i = 0; i <
|
|
2281
|
+
for (let i = 0; i < this.blockLength - 1; i++)
|
|
1812
2282
|
retView[i] = curView[i] | 0x80;
|
|
1813
2283
|
retView[this.blockLength - 1] = curView[this.blockLength - 1];
|
|
1814
|
-
return retView
|
|
2284
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(retView);
|
|
1815
2285
|
}
|
|
1816
2286
|
const encodedBuf = pvutils__namespace.utilToBase(this.valueDec, 7);
|
|
1817
2287
|
if (encodedBuf.byteLength === 0) {
|
|
@@ -1826,7 +2296,7 @@ class LocalSidValueBlock extends HexBlock(ValueBlock) {
|
|
|
1826
2296
|
retView[i] = encodedView[i] | 0x80;
|
|
1827
2297
|
retView[len] = encodedView[len];
|
|
1828
2298
|
}
|
|
1829
|
-
return retView;
|
|
2299
|
+
return pvtsutils__namespace.BufferSourceConverter.toArrayBuffer(retView);
|
|
1830
2300
|
}
|
|
1831
2301
|
toString() {
|
|
1832
2302
|
let result = "";
|
|
@@ -1858,7 +2328,7 @@ class LocalSidValueBlock extends HexBlock(ValueBlock) {
|
|
|
1858
2328
|
return {
|
|
1859
2329
|
...super.toJSON(),
|
|
1860
2330
|
valueDec: this.valueDec,
|
|
1861
|
-
isFirstSid: this.isFirstSid
|
|
2331
|
+
isFirstSid: this.isFirstSid
|
|
1862
2332
|
};
|
|
1863
2333
|
}
|
|
1864
2334
|
}
|
|
@@ -1981,7 +2451,7 @@ class LocalObjectIdentifierValueBlock extends ValueBlock {
|
|
|
1981
2451
|
const object = {
|
|
1982
2452
|
...super.toJSON(),
|
|
1983
2453
|
value: this.toString(),
|
|
1984
|
-
sidArray: []
|
|
2454
|
+
sidArray: []
|
|
1985
2455
|
};
|
|
1986
2456
|
for (let i = 0; i < this.value.length; i++) {
|
|
1987
2457
|
object.sidArray.push(this.value[i].toJSON());
|
|
@@ -2010,7 +2480,7 @@ class ObjectIdentifier extends BaseBlock {
|
|
|
2010
2480
|
toJSON() {
|
|
2011
2481
|
return {
|
|
2012
2482
|
...super.toJSON(),
|
|
2013
|
-
value: this.getValue()
|
|
2483
|
+
value: this.getValue()
|
|
2014
2484
|
};
|
|
2015
2485
|
}
|
|
2016
2486
|
}
|
|
@@ -2032,17 +2502,33 @@ class LocalRelativeSidValueBlock extends HexBlock(LocalBaseBlock) {
|
|
|
2032
2502
|
if (!checkBufferParams(this, inputView, inputOffset, inputLength))
|
|
2033
2503
|
return -1;
|
|
2034
2504
|
const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength);
|
|
2035
|
-
this.
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2505
|
+
const fastPath = this.blockLength === 0 && Number.isInteger(inputOffset) && Number.isInteger(inputLength);
|
|
2506
|
+
if (fastPath) {
|
|
2507
|
+
let sidLength = 0;
|
|
2508
|
+
while (sidLength < inputLength) {
|
|
2509
|
+
const octet = intBuffer[sidLength];
|
|
2510
|
+
sidLength++;
|
|
2511
|
+
if ((octet & 0x80) === 0x00)
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
this.blockLength = sidLength;
|
|
2515
|
+
this.valueHexView = new Uint8Array(sidLength);
|
|
2516
|
+
for (let i = 0; i < sidLength; i++)
|
|
2517
|
+
this.valueHexView[i] = intBuffer[i] & 0x7f;
|
|
2518
|
+
}
|
|
2519
|
+
else {
|
|
2520
|
+
this.valueHexView = new Uint8Array(inputLength);
|
|
2521
|
+
for (let i = 0; i < inputLength; i++) {
|
|
2522
|
+
this.valueHexView[i] = intBuffer[i] & 0x7f;
|
|
2523
|
+
this.blockLength++;
|
|
2524
|
+
if ((intBuffer[i] & 0x80) === 0x00)
|
|
2525
|
+
break;
|
|
2526
|
+
}
|
|
2527
|
+
const tempView = new Uint8Array(this.blockLength);
|
|
2528
|
+
for (let i = 0; i < this.blockLength; i++)
|
|
2529
|
+
tempView[i] = this.valueHexView[i];
|
|
2530
|
+
this.valueHexView = tempView;
|
|
2041
2531
|
}
|
|
2042
|
-
const tempView = new Uint8Array(this.blockLength);
|
|
2043
|
-
for (let i = 0; i < this.blockLength; i++)
|
|
2044
|
-
tempView[i] = this.valueHexView[i];
|
|
2045
|
-
this.valueHexView = tempView;
|
|
2046
2532
|
if ((intBuffer[this.blockLength - 1] & 0x80) !== 0x00) {
|
|
2047
2533
|
this.error = "End of input reached before message was fully decoded";
|
|
2048
2534
|
return -1;
|
|
@@ -2055,15 +2541,15 @@ class LocalRelativeSidValueBlock extends HexBlock(LocalBaseBlock) {
|
|
|
2055
2541
|
this.isHexOnly = true;
|
|
2056
2542
|
this.warnings.push("Too big SID for decoding, hex only");
|
|
2057
2543
|
}
|
|
2058
|
-
return
|
|
2544
|
+
return inputOffset + this.blockLength;
|
|
2059
2545
|
}
|
|
2060
2546
|
toBER(sizeOnly) {
|
|
2061
2547
|
if (this.isHexOnly) {
|
|
2062
2548
|
if (sizeOnly)
|
|
2063
|
-
return
|
|
2549
|
+
return new ArrayBuffer(this.valueHexView.byteLength);
|
|
2064
2550
|
const curView = this.valueHexView;
|
|
2065
2551
|
const retView = new Uint8Array(this.blockLength);
|
|
2066
|
-
for (let i = 0; i <
|
|
2552
|
+
for (let i = 0; i < this.blockLength - 1; i++)
|
|
2067
2553
|
retView[i] = curView[i] | 0x80;
|
|
2068
2554
|
retView[this.blockLength - 1] = curView[this.blockLength - 1];
|
|
2069
2555
|
return retView.buffer;
|
|
@@ -2095,7 +2581,7 @@ class LocalRelativeSidValueBlock extends HexBlock(LocalBaseBlock) {
|
|
|
2095
2581
|
toJSON() {
|
|
2096
2582
|
return {
|
|
2097
2583
|
...super.toJSON(),
|
|
2098
|
-
valueDec: this.valueDec
|
|
2584
|
+
valueDec: this.valueDec
|
|
2099
2585
|
};
|
|
2100
2586
|
}
|
|
2101
2587
|
}
|
|
@@ -2178,7 +2664,7 @@ class LocalRelativeObjectIdentifierValueBlock extends ValueBlock {
|
|
|
2178
2664
|
const object = {
|
|
2179
2665
|
...super.toJSON(),
|
|
2180
2666
|
value: this.toString(),
|
|
2181
|
-
sidArray: []
|
|
2667
|
+
sidArray: []
|
|
2182
2668
|
};
|
|
2183
2669
|
for (let i = 0; i < this.value.length; i++)
|
|
2184
2670
|
object.sidArray.push(this.value[i].toJSON());
|
|
@@ -2206,7 +2692,7 @@ class RelativeObjectIdentifier extends BaseBlock {
|
|
|
2206
2692
|
toJSON() {
|
|
2207
2693
|
return {
|
|
2208
2694
|
...super.toJSON(),
|
|
2209
|
-
value: this.getValue()
|
|
2695
|
+
value: this.getValue()
|
|
2210
2696
|
};
|
|
2211
2697
|
}
|
|
2212
2698
|
}
|
|
@@ -2253,7 +2739,7 @@ class LocalStringValueBlock extends HexBlock(ValueBlock) {
|
|
|
2253
2739
|
toJSON() {
|
|
2254
2740
|
return {
|
|
2255
2741
|
...super.toJSON(),
|
|
2256
|
-
value: this.value
|
|
2742
|
+
value: this.value
|
|
2257
2743
|
};
|
|
2258
2744
|
}
|
|
2259
2745
|
}
|
|
@@ -2272,7 +2758,7 @@ class LocalSimpleStringBlock extends BaseStringBlock {
|
|
|
2272
2758
|
}
|
|
2273
2759
|
fromString(inputString) {
|
|
2274
2760
|
const strLen = inputString.length;
|
|
2275
|
-
const view = this.valueBlock.valueHexView = new Uint8Array(strLen);
|
|
2761
|
+
const view = (this.valueBlock.valueHexView = new Uint8Array(strLen));
|
|
2276
2762
|
for (let i = 0; i < strLen; i++)
|
|
2277
2763
|
view[i] = inputString.charCodeAt(i);
|
|
2278
2764
|
this.valueBlock.value = inputString;
|
|
@@ -2352,14 +2838,14 @@ class LocalUniversalStringValueBlock extends LocalSimpleStringBlock {
|
|
|
2352
2838
|
}
|
|
2353
2839
|
fromString(inputString) {
|
|
2354
2840
|
const strLength = inputString.length;
|
|
2355
|
-
const valueHexView = this.valueBlock.valueHexView = new Uint8Array(strLength * 4);
|
|
2841
|
+
const valueHexView = (this.valueBlock.valueHexView = new Uint8Array(strLength * 4));
|
|
2356
2842
|
for (let i = 0; i < strLength; i++) {
|
|
2357
2843
|
const codeBuf = pvutils__namespace.utilToBase(inputString.charCodeAt(i), 8);
|
|
2358
2844
|
const codeView = new Uint8Array(codeBuf);
|
|
2359
2845
|
if (codeView.length > 4)
|
|
2360
2846
|
continue;
|
|
2361
2847
|
const dif = 4 - codeView.length;
|
|
2362
|
-
for (let j =
|
|
2848
|
+
for (let j = codeView.length - 1; j >= 0; j--)
|
|
2363
2849
|
valueHexView[i * 4 + j + dif] = codeView[j];
|
|
2364
2850
|
}
|
|
2365
2851
|
this.valueBlock.value = inputString;
|
|
@@ -2550,10 +3036,10 @@ class UTCTime extends VisibleString {
|
|
|
2550
3036
|
this.second = inputDate.getUTCSeconds();
|
|
2551
3037
|
}
|
|
2552
3038
|
toDate() {
|
|
2553
|
-
return
|
|
3039
|
+
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second));
|
|
2554
3040
|
}
|
|
2555
3041
|
fromString(inputString) {
|
|
2556
|
-
const parser = /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/
|
|
3042
|
+
const parser = /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi;
|
|
2557
3043
|
const parserArray = parser.exec(inputString);
|
|
2558
3044
|
if (parserArray === null) {
|
|
2559
3045
|
this.error = "Wrong input string for conversion";
|
|
@@ -2572,8 +3058,8 @@ class UTCTime extends VisibleString {
|
|
|
2572
3058
|
}
|
|
2573
3059
|
toString(encoding = "iso") {
|
|
2574
3060
|
if (encoding === "iso") {
|
|
2575
|
-
const outputArray =
|
|
2576
|
-
outputArray[0] = pvutils__namespace.padNumber(
|
|
3061
|
+
const outputArray = Array.from({ length: 7 });
|
|
3062
|
+
outputArray[0] = pvutils__namespace.padNumber(this.year < 2000 ? this.year - 1900 : this.year - 2000, 2);
|
|
2577
3063
|
outputArray[1] = pvutils__namespace.padNumber(this.month, 2);
|
|
2578
3064
|
outputArray[2] = pvutils__namespace.padNumber(this.day, 2);
|
|
2579
3065
|
outputArray[3] = pvutils__namespace.padNumber(this.hour, 2);
|
|
@@ -2595,7 +3081,7 @@ class UTCTime extends VisibleString {
|
|
|
2595
3081
|
day: this.day,
|
|
2596
3082
|
hour: this.hour,
|
|
2597
3083
|
minute: this.minute,
|
|
2598
|
-
second: this.second
|
|
3084
|
+
second: this.second
|
|
2599
3085
|
};
|
|
2600
3086
|
}
|
|
2601
3087
|
}
|
|
@@ -2620,7 +3106,7 @@ class GeneralizedTime extends UTCTime {
|
|
|
2620
3106
|
}
|
|
2621
3107
|
toDate() {
|
|
2622
3108
|
const utcDate = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
2623
|
-
return
|
|
3109
|
+
return new Date(utcDate);
|
|
2624
3110
|
}
|
|
2625
3111
|
fromString(inputString) {
|
|
2626
3112
|
let isUTC = false;
|
|
@@ -2657,7 +3143,7 @@ class GeneralizedTime extends UTCTime {
|
|
|
2657
3143
|
if (differencePosition !== -1) {
|
|
2658
3144
|
differenceString = timeString.substring(differencePosition + 1);
|
|
2659
3145
|
timeString = timeString.substring(0, differencePosition);
|
|
2660
|
-
if (
|
|
3146
|
+
if (differenceString.length !== 2 && differenceString.length !== 4)
|
|
2661
3147
|
throw new Error("Wrong input string for conversion");
|
|
2662
3148
|
let number = parseInt(differenceString.substring(0, 2), 10);
|
|
2663
3149
|
if (isNaN(number.valueOf()))
|
|
@@ -2684,13 +3170,13 @@ class GeneralizedTime extends UTCTime {
|
|
|
2684
3170
|
else
|
|
2685
3171
|
dateTimeString = timeString;
|
|
2686
3172
|
switch (true) {
|
|
2687
|
-
case
|
|
2688
|
-
parser = /(\d{4})(\d{2})(\d{2})/
|
|
3173
|
+
case dateTimeString.length === 8:
|
|
3174
|
+
parser = /(\d{4})(\d{2})(\d{2})/gi;
|
|
2689
3175
|
if (fractionPointPosition !== -1)
|
|
2690
3176
|
throw new Error("Wrong input string for conversion");
|
|
2691
3177
|
break;
|
|
2692
|
-
case
|
|
2693
|
-
parser = /(\d{4})(\d{2})(\d{2})(\d{2})/
|
|
3178
|
+
case dateTimeString.length === 10:
|
|
3179
|
+
parser = /(\d{4})(\d{2})(\d{2})(\d{2})/gi;
|
|
2694
3180
|
if (fractionPointPosition !== -1) {
|
|
2695
3181
|
let fractionResult = 60 * fractionPart;
|
|
2696
3182
|
this.minute = Math.floor(fractionResult);
|
|
@@ -2700,8 +3186,8 @@ class GeneralizedTime extends UTCTime {
|
|
|
2700
3186
|
this.millisecond = Math.floor(fractionResult);
|
|
2701
3187
|
}
|
|
2702
3188
|
break;
|
|
2703
|
-
case
|
|
2704
|
-
parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/
|
|
3189
|
+
case dateTimeString.length === 12:
|
|
3190
|
+
parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi;
|
|
2705
3191
|
if (fractionPointPosition !== -1) {
|
|
2706
3192
|
let fractionResult = 60 * fractionPart;
|
|
2707
3193
|
this.second = Math.floor(fractionResult);
|
|
@@ -2709,8 +3195,8 @@ class GeneralizedTime extends UTCTime {
|
|
|
2709
3195
|
this.millisecond = Math.floor(fractionResult);
|
|
2710
3196
|
}
|
|
2711
3197
|
break;
|
|
2712
|
-
case
|
|
2713
|
-
parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
|
|
3198
|
+
case dateTimeString.length === 14:
|
|
3199
|
+
parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi;
|
|
2714
3200
|
if (fractionPointPosition !== -1) {
|
|
2715
3201
|
const fractionResult = 1000 * fractionPart;
|
|
2716
3202
|
this.millisecond = Math.floor(fractionResult);
|
|
@@ -2768,7 +3254,7 @@ class GeneralizedTime extends UTCTime {
|
|
|
2768
3254
|
outputArray.push(pvutils__namespace.padNumber(this.second, 2));
|
|
2769
3255
|
if (this.millisecond !== 0) {
|
|
2770
3256
|
outputArray.push(".");
|
|
2771
|
-
outputArray.push(pvutils__namespace.padNumber(this.millisecond, 3));
|
|
3257
|
+
outputArray.push(pvutils__namespace.padNumber(this.millisecond, 3).replace(/0+$/, ""));
|
|
2772
3258
|
}
|
|
2773
3259
|
outputArray.push("Z");
|
|
2774
3260
|
return outputArray.join("");
|
|
@@ -2778,7 +3264,7 @@ class GeneralizedTime extends UTCTime {
|
|
|
2778
3264
|
toJSON() {
|
|
2779
3265
|
return {
|
|
2780
3266
|
...super.toJSON(),
|
|
2781
|
-
millisecond: this.millisecond
|
|
3267
|
+
millisecond: this.millisecond
|
|
2782
3268
|
};
|
|
2783
3269
|
}
|
|
2784
3270
|
}
|
|
@@ -2907,14 +3393,14 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
2907
3393
|
if (result.verified) {
|
|
2908
3394
|
return {
|
|
2909
3395
|
verified: true,
|
|
2910
|
-
result: root
|
|
3396
|
+
result: root
|
|
2911
3397
|
};
|
|
2912
3398
|
}
|
|
2913
3399
|
}
|
|
2914
3400
|
{
|
|
2915
3401
|
const _result = {
|
|
2916
3402
|
verified: false,
|
|
2917
|
-
result: { error: "Wrong values for Choice type" }
|
|
3403
|
+
result: { error: "Wrong values for Choice type" }
|
|
2918
3404
|
};
|
|
2919
3405
|
if (inputSchema.hasOwnProperty(NAME))
|
|
2920
3406
|
_result.name = inputSchema.name;
|
|
@@ -2926,112 +3412,112 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
2926
3412
|
root[inputSchema.name] = inputData;
|
|
2927
3413
|
return {
|
|
2928
3414
|
verified: true,
|
|
2929
|
-
result: root
|
|
3415
|
+
result: root
|
|
2930
3416
|
};
|
|
2931
3417
|
}
|
|
2932
|
-
if (
|
|
3418
|
+
if (root instanceof Object === false) {
|
|
2933
3419
|
return {
|
|
2934
3420
|
verified: false,
|
|
2935
|
-
result: { error: "Wrong root object" }
|
|
3421
|
+
result: { error: "Wrong root object" }
|
|
2936
3422
|
};
|
|
2937
3423
|
}
|
|
2938
|
-
if (
|
|
3424
|
+
if (inputData instanceof Object === false) {
|
|
2939
3425
|
return {
|
|
2940
3426
|
verified: false,
|
|
2941
|
-
result: { error: "Wrong ASN.1 data" }
|
|
3427
|
+
result: { error: "Wrong ASN.1 data" }
|
|
2942
3428
|
};
|
|
2943
3429
|
}
|
|
2944
|
-
if (
|
|
3430
|
+
if (inputSchema instanceof Object === false) {
|
|
2945
3431
|
return {
|
|
2946
3432
|
verified: false,
|
|
2947
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3433
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2948
3434
|
};
|
|
2949
3435
|
}
|
|
2950
|
-
if (
|
|
3436
|
+
if (ID_BLOCK in inputSchema === false) {
|
|
2951
3437
|
return {
|
|
2952
3438
|
verified: false,
|
|
2953
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3439
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2954
3440
|
};
|
|
2955
3441
|
}
|
|
2956
|
-
if (
|
|
3442
|
+
if (FROM_BER in inputSchema.idBlock === false) {
|
|
2957
3443
|
return {
|
|
2958
3444
|
verified: false,
|
|
2959
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3445
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2960
3446
|
};
|
|
2961
3447
|
}
|
|
2962
|
-
if (
|
|
3448
|
+
if (TO_BER in inputSchema.idBlock === false) {
|
|
2963
3449
|
return {
|
|
2964
3450
|
verified: false,
|
|
2965
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3451
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2966
3452
|
};
|
|
2967
3453
|
}
|
|
2968
3454
|
const encodedId = inputSchema.idBlock.toBER(false);
|
|
2969
3455
|
if (encodedId.byteLength === 0) {
|
|
2970
3456
|
return {
|
|
2971
3457
|
verified: false,
|
|
2972
|
-
result: { error: "Error encoding idBlock for ASN.1 schema" }
|
|
3458
|
+
result: { error: "Error encoding idBlock for ASN.1 schema" }
|
|
2973
3459
|
};
|
|
2974
3460
|
}
|
|
2975
3461
|
const decodedOffset = inputSchema.idBlock.fromBER(encodedId, 0, encodedId.byteLength);
|
|
2976
3462
|
if (decodedOffset === -1) {
|
|
2977
3463
|
return {
|
|
2978
3464
|
verified: false,
|
|
2979
|
-
result: { error: "Error decoding idBlock for ASN.1 schema" }
|
|
3465
|
+
result: { error: "Error decoding idBlock for ASN.1 schema" }
|
|
2980
3466
|
};
|
|
2981
3467
|
}
|
|
2982
3468
|
if (inputSchema.idBlock.hasOwnProperty(TAG_CLASS) === false) {
|
|
2983
3469
|
return {
|
|
2984
3470
|
verified: false,
|
|
2985
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3471
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2986
3472
|
};
|
|
2987
3473
|
}
|
|
2988
3474
|
if (inputSchema.idBlock.tagClass !== inputData.idBlock.tagClass) {
|
|
2989
3475
|
return {
|
|
2990
3476
|
verified: false,
|
|
2991
|
-
result: root
|
|
3477
|
+
result: root
|
|
2992
3478
|
};
|
|
2993
3479
|
}
|
|
2994
3480
|
if (inputSchema.idBlock.hasOwnProperty(TAG_NUMBER) === false) {
|
|
2995
3481
|
return {
|
|
2996
3482
|
verified: false,
|
|
2997
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3483
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
2998
3484
|
};
|
|
2999
3485
|
}
|
|
3000
3486
|
if (inputSchema.idBlock.tagNumber !== inputData.idBlock.tagNumber) {
|
|
3001
3487
|
return {
|
|
3002
3488
|
verified: false,
|
|
3003
|
-
result: root
|
|
3489
|
+
result: root
|
|
3004
3490
|
};
|
|
3005
3491
|
}
|
|
3006
3492
|
if (inputSchema.idBlock.hasOwnProperty(IS_CONSTRUCTED) === false) {
|
|
3007
3493
|
return {
|
|
3008
3494
|
verified: false,
|
|
3009
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3495
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
3010
3496
|
};
|
|
3011
3497
|
}
|
|
3012
3498
|
if (inputSchema.idBlock.isConstructed !== inputData.idBlock.isConstructed) {
|
|
3013
3499
|
return {
|
|
3014
3500
|
verified: false,
|
|
3015
|
-
result: root
|
|
3501
|
+
result: root
|
|
3016
3502
|
};
|
|
3017
3503
|
}
|
|
3018
3504
|
if (!(IS_HEX_ONLY in inputSchema.idBlock)) {
|
|
3019
3505
|
return {
|
|
3020
3506
|
verified: false,
|
|
3021
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3507
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
3022
3508
|
};
|
|
3023
3509
|
}
|
|
3024
3510
|
if (inputSchema.idBlock.isHexOnly !== inputData.idBlock.isHexOnly) {
|
|
3025
3511
|
return {
|
|
3026
3512
|
verified: false,
|
|
3027
|
-
result: root
|
|
3513
|
+
result: root
|
|
3028
3514
|
};
|
|
3029
3515
|
}
|
|
3030
3516
|
if (inputSchema.idBlock.isHexOnly) {
|
|
3031
|
-
if (
|
|
3517
|
+
if (VALUE_HEX_VIEW in inputSchema.idBlock === false) {
|
|
3032
3518
|
return {
|
|
3033
3519
|
verified: false,
|
|
3034
|
-
result: { error: "Wrong ASN.1 schema" }
|
|
3520
|
+
result: { error: "Wrong ASN.1 schema" }
|
|
3035
3521
|
};
|
|
3036
3522
|
}
|
|
3037
3523
|
const schemaView = inputSchema.idBlock.valueHexView;
|
|
@@ -3039,14 +3525,14 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3039
3525
|
if (schemaView.length !== asn1View.length) {
|
|
3040
3526
|
return {
|
|
3041
3527
|
verified: false,
|
|
3042
|
-
result: root
|
|
3528
|
+
result: root
|
|
3043
3529
|
};
|
|
3044
3530
|
}
|
|
3045
3531
|
for (let i = 0; i < schemaView.length; i++) {
|
|
3046
3532
|
if (schemaView[i] !== asn1View[1]) {
|
|
3047
3533
|
return {
|
|
3048
3534
|
verified: false,
|
|
3049
|
-
result: root
|
|
3535
|
+
result: root
|
|
3050
3536
|
};
|
|
3051
3537
|
}
|
|
3052
3538
|
}
|
|
@@ -3060,7 +3546,7 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3060
3546
|
let admission = 0;
|
|
3061
3547
|
let result = {
|
|
3062
3548
|
verified: false,
|
|
3063
|
-
result: { error: "Unknown error" }
|
|
3549
|
+
result: { error: "Unknown error" }
|
|
3064
3550
|
};
|
|
3065
3551
|
let maxLength = inputSchema.valueBlock.value.length;
|
|
3066
3552
|
if (maxLength > 0) {
|
|
@@ -3071,18 +3557,17 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3071
3557
|
if (maxLength === 0) {
|
|
3072
3558
|
return {
|
|
3073
3559
|
verified: true,
|
|
3074
|
-
result: root
|
|
3560
|
+
result: root
|
|
3075
3561
|
};
|
|
3076
3562
|
}
|
|
3077
|
-
if (
|
|
3078
|
-
&& (inputSchema.valueBlock.value.length !== 0)) {
|
|
3563
|
+
if (inputData.valueBlock.value.length === 0 && inputSchema.valueBlock.value.length !== 0) {
|
|
3079
3564
|
let _optional = true;
|
|
3080
3565
|
for (let i = 0; i < inputSchema.valueBlock.value.length; i++)
|
|
3081
3566
|
_optional = _optional && (inputSchema.valueBlock.value[i].optional || false);
|
|
3082
3567
|
if (_optional) {
|
|
3083
3568
|
return {
|
|
3084
3569
|
verified: true,
|
|
3085
|
-
result: root
|
|
3570
|
+
result: root
|
|
3086
3571
|
};
|
|
3087
3572
|
}
|
|
3088
3573
|
if (inputSchema.name) {
|
|
@@ -3093,15 +3578,15 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3093
3578
|
root.error = "Inconsistent object length";
|
|
3094
3579
|
return {
|
|
3095
3580
|
verified: false,
|
|
3096
|
-
result: root
|
|
3581
|
+
result: root
|
|
3097
3582
|
};
|
|
3098
3583
|
}
|
|
3099
3584
|
for (let i = 0; i < maxLength; i++) {
|
|
3100
|
-
if (
|
|
3585
|
+
if (i - admission >= inputData.valueBlock.value.length) {
|
|
3101
3586
|
if (inputSchema.valueBlock.value[i].optional === false) {
|
|
3102
3587
|
const _result = {
|
|
3103
3588
|
verified: false,
|
|
3104
|
-
result: root
|
|
3589
|
+
result: root
|
|
3105
3590
|
};
|
|
3106
3591
|
root.error = "Inconsistent length between ASN.1 data and schema";
|
|
3107
3592
|
if (inputSchema.name) {
|
|
@@ -3129,9 +3614,9 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3129
3614
|
return result;
|
|
3130
3615
|
}
|
|
3131
3616
|
}
|
|
3132
|
-
if (
|
|
3617
|
+
if (NAME in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].name.length > 0) {
|
|
3133
3618
|
let arrayRoot = {};
|
|
3134
|
-
if (
|
|
3619
|
+
if (LOCAL in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].local)
|
|
3135
3620
|
arrayRoot = inputData;
|
|
3136
3621
|
else
|
|
3137
3622
|
arrayRoot = root;
|
|
@@ -3160,7 +3645,7 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3160
3645
|
if (result.verified === false) {
|
|
3161
3646
|
const _result = {
|
|
3162
3647
|
verified: false,
|
|
3163
|
-
result: root
|
|
3648
|
+
result: root
|
|
3164
3649
|
};
|
|
3165
3650
|
if (inputSchema.name) {
|
|
3166
3651
|
inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
|
|
@@ -3173,16 +3658,15 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3173
3658
|
}
|
|
3174
3659
|
return {
|
|
3175
3660
|
verified: true,
|
|
3176
|
-
result: root
|
|
3661
|
+
result: root
|
|
3177
3662
|
};
|
|
3178
3663
|
}
|
|
3179
|
-
if (inputSchema.primitiveSchema
|
|
3180
|
-
&& (VALUE_HEX_VIEW in inputData.valueBlock)) {
|
|
3664
|
+
if (inputSchema.primitiveSchema && VALUE_HEX_VIEW in inputData.valueBlock) {
|
|
3181
3665
|
const asn1 = localFromBER(inputData.valueBlock.valueHexView);
|
|
3182
3666
|
if (asn1.offset === -1) {
|
|
3183
3667
|
const _result = {
|
|
3184
3668
|
verified: false,
|
|
3185
|
-
result: asn1.result
|
|
3669
|
+
result: asn1.result
|
|
3186
3670
|
};
|
|
3187
3671
|
if (inputSchema.name) {
|
|
3188
3672
|
inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING);
|
|
@@ -3197,26 +3681,49 @@ function compareSchema(root, inputData, inputSchema) {
|
|
|
3197
3681
|
}
|
|
3198
3682
|
return {
|
|
3199
3683
|
verified: true,
|
|
3200
|
-
result: root
|
|
3684
|
+
result: root
|
|
3201
3685
|
};
|
|
3202
3686
|
}
|
|
3203
3687
|
function verifySchema(inputBuffer, inputSchema) {
|
|
3204
|
-
if (
|
|
3688
|
+
if (inputSchema instanceof Object === false) {
|
|
3205
3689
|
return {
|
|
3206
3690
|
verified: false,
|
|
3207
|
-
result: { error: "Wrong ASN.1 schema type" }
|
|
3691
|
+
result: { error: "Wrong ASN.1 schema type" }
|
|
3208
3692
|
};
|
|
3209
3693
|
}
|
|
3210
3694
|
const asn1 = localFromBER(pvtsutils__namespace.BufferSourceConverter.toUint8Array(inputBuffer));
|
|
3211
3695
|
if (asn1.offset === -1) {
|
|
3212
3696
|
return {
|
|
3213
3697
|
verified: false,
|
|
3214
|
-
result: asn1.result
|
|
3698
|
+
result: asn1.result
|
|
3215
3699
|
};
|
|
3216
3700
|
}
|
|
3217
3701
|
return compareSchema(asn1.result, asn1.result, inputSchema);
|
|
3218
3702
|
}
|
|
3219
3703
|
|
|
3704
|
+
registerBuiltinEncoder({ BitString, Integer, OctetString, Primitive, Constructed, Sequence, Set }, {
|
|
3705
|
+
BaseBlock,
|
|
3706
|
+
ViewWriter,
|
|
3707
|
+
LocalIdentificationBlock,
|
|
3708
|
+
LocalLengthBlock,
|
|
3709
|
+
LocalIntegerValueBlock,
|
|
3710
|
+
LocalOctetStringValueBlock,
|
|
3711
|
+
LocalConstructedValueBlock,
|
|
3712
|
+
LocalBitStringValueBlock,
|
|
3713
|
+
LocalPrimitiveValueBlock,
|
|
3714
|
+
originalBaseBlockToBER: ORIGINAL_BASE_BLOCK_TO_BER,
|
|
3715
|
+
originalWriterWrite: ORIGINAL_VIEW_WRITER_WRITE,
|
|
3716
|
+
originalWriterFinal: ORIGINAL_VIEW_WRITER_FINAL,
|
|
3717
|
+
originalIdentificationToBER: ORIGINAL_LOCAL_IDENTIFICATION_TO_BER,
|
|
3718
|
+
originalLengthToBER: ORIGINAL_LOCAL_LENGTH_TO_BER,
|
|
3719
|
+
originalIntegerToBER: ORIGINAL_LOCAL_INTEGER_TO_BER,
|
|
3720
|
+
originalOctetStringToBER: ORIGINAL_LOCAL_OCTET_STRING_TO_BER,
|
|
3721
|
+
originalBitStringToBER: ORIGINAL_LOCAL_BIT_STRING_TO_BER,
|
|
3722
|
+
originalConstructedToBER: ORIGINAL_LOCAL_CONSTRUCTED_TO_BER,
|
|
3723
|
+
originalPrimitiveToBER: ORIGINAL_LOCAL_PRIMITIVE_TO_BER
|
|
3724
|
+
});
|
|
3725
|
+
registerFastParser({ Integer, Null, Sequence });
|
|
3726
|
+
|
|
3220
3727
|
exports.Any = Any;
|
|
3221
3728
|
exports.BaseBlock = BaseBlock;
|
|
3222
3729
|
exports.BaseStringBlock = BaseStringBlock;
|