@deepseek-harness-tui/dsh-tui 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -15
- package/cordis.patch.yml +21 -2
- package/cordis.yml +12 -1
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
- package/dsh-ecosystem-spec/registry/README.md +14 -0
- package/dsh-ecosystem-spec/registry/contracts/decision-events-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
- package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
- package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -0
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -0
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
- package/dsh-ecosystem-spec/schemas/conformance-claim.schema.json +15 -0
- package/dsh-ecosystem-spec/schemas/effect-ledger-record.schema.json +16 -0
- package/dsh-ecosystem-spec/schemas/host-descriptor.schema.json +26 -0
- package/lib/types/cc/figures.d.ts +4 -0
- package/lib/types/cc/figures.d.ts.map +1 -1
- package/lib/types/cc/figures.js +4 -0
- package/lib/types/command-trees.d.ts +2 -1
- package/lib/types/command-trees.d.ts.map +1 -1
- package/lib/types/command-trees.js +1 -1
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +2 -0
- package/lib/types/components/ExtensionDialog.d.ts +40 -0
- package/lib/types/components/ExtensionDialog.d.ts.map +1 -0
- package/lib/types/components/ExtensionDialog.js +210 -0
- package/lib/types/components/HelpMenu.js +1 -1
- package/lib/types/components/LoadedContextPanel.d.ts +5 -5
- package/lib/types/components/LoadedContextPanel.js +6 -6
- package/lib/types/components/LogoV2.d.ts.map +1 -1
- package/lib/types/components/LogoV2.js +16 -8
- package/lib/types/components/Markdown.d.ts +13 -1
- package/lib/types/components/Markdown.d.ts.map +1 -1
- package/lib/types/components/Markdown.js +15 -1
- package/lib/types/components/MessageList.d.ts +3 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +111 -6
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +26 -12
- package/lib/types/components/RewindPicker.d.ts +13 -1
- package/lib/types/components/RewindPicker.d.ts.map +1 -1
- package/lib/types/components/RewindPicker.js +26 -2
- package/lib/types/components/StreamingMarkdown.d.ts +2 -8
- package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
- package/lib/types/components/StreamingMarkdown.js +51 -9
- package/lib/types/components/ToolUseLoader.d.ts +8 -3
- package/lib/types/components/ToolUseLoader.d.ts.map +1 -1
- package/lib/types/components/ToolUseLoader.js +43 -9
- package/lib/types/components/activityFrames.d.ts +1 -1
- package/lib/types/components/activityFrames.d.ts.map +1 -1
- package/lib/types/components/activityFrames.js +4 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +13 -2
- package/lib/types/dsh-adapter/channel.d.ts +61 -11
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +767 -120
- package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
- package/lib/types/dsh-adapter/childStderr.js +10 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts +51 -0
- package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-attribution.js +93 -0
- package/lib/types/dsh-adapter/command-errors.d.ts +42 -0
- package/lib/types/dsh-adapter/command-errors.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-errors.js +63 -0
- package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
- package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
- package/lib/types/dsh-adapter/command-trees.js +70 -20
- package/lib/types/dsh-adapter/component-identity.d.ts +33 -0
- package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -0
- package/lib/types/dsh-adapter/component-identity.js +108 -0
- package/lib/types/dsh-adapter/contract.d.ts +1 -1
- package/lib/types/dsh-adapter/contract.js +2 -2
- package/lib/types/dsh-adapter/decision-guard.d.ts +84 -0
- package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -0
- package/lib/types/dsh-adapter/decision-guard.js +348 -0
- package/lib/types/dsh-adapter/dialogs.d.ts +145 -0
- package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -0
- package/lib/types/dsh-adapter/dialogs.js +316 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts +91 -0
- package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -0
- package/lib/types/dsh-adapter/effect-ledger.js +251 -0
- package/lib/types/dsh-adapter/extension-events.d.ts +193 -0
- package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extension-events.js +207 -0
- package/lib/types/dsh-adapter/extensions.d.ts +32 -0
- package/lib/types/dsh-adapter/extensions.d.ts.map +1 -0
- package/lib/types/dsh-adapter/extensions.js +42 -0
- package/lib/types/dsh-adapter/grants.d.ts +25 -0
- package/lib/types/dsh-adapter/grants.d.ts.map +1 -0
- package/lib/types/dsh-adapter/grants.js +213 -0
- package/lib/types/dsh-adapter/host-access.d.ts +37 -0
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-access.js +652 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts +24 -0
- package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -0
- package/lib/types/dsh-adapter/host-descriptor.js +169 -0
- package/lib/types/dsh-adapter/index.d.ts +4 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/message-observer.d.ts +173 -0
- package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -0
- package/lib/types/dsh-adapter/message-observer.js +553 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts +136 -0
- package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-host.js +365 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts +108 -0
- package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugin-storage.js +397 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +124 -14
- package/lib/types/dsh-adapter/plugins-info.d.ts +43 -0
- package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -0
- package/lib/types/dsh-adapter/plugins-info.js +276 -0
- package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
- package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
- package/lib/types/dsh-adapter/promptDebug.js +13 -4
- package/lib/types/dsh-adapter/renderers.d.ts +57 -0
- package/lib/types/dsh-adapter/renderers.d.ts.map +1 -0
- package/lib/types/dsh-adapter/renderers.js +173 -0
- package/lib/types/dsh-adapter/sanitize.d.ts +36 -0
- package/lib/types/dsh-adapter/sanitize.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sanitize.js +65 -0
- package/lib/types/dsh-adapter/scenes.d.ts +15 -5
- package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
- package/lib/types/dsh-adapter/scenes.js +149 -35
- package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +106 -26
- package/lib/types/dsh-adapter/shortcuts.d.ts +107 -0
- package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -0
- package/lib/types/dsh-adapter/shortcuts.js +340 -0
- package/lib/types/dsh-adapter/status.d.ts +74 -0
- package/lib/types/dsh-adapter/status.d.ts.map +1 -0
- package/lib/types/dsh-adapter/status.js +234 -0
- package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
- package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
- package/lib/types/dsh-adapter/workspaces.js +287 -170
- package/lib/types/extensions.d.ts +13 -0
- package/lib/types/extensions.d.ts.map +1 -0
- package/lib/types/extensions.js +21 -0
- package/lib/types/force-production-react.d.ts +1 -0
- package/lib/types/force-production-react.d.ts.map +1 -0
- package/lib/types/force-production-react.js +12 -0
- package/lib/types/i18n.d.ts +174 -20
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +56 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/ink/components/App.d.ts +2 -0
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +4 -0
- package/lib/types/ink/ink.d.ts +31 -3
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +90 -5
- package/lib/types/ink/log-update.d.ts.map +1 -1
- package/lib/types/ink/log-update.js +225 -56
- package/lib/types/ink/output.d.ts +35 -2
- package/lib/types/ink/output.d.ts.map +1 -1
- package/lib/types/ink/output.js +281 -14
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
- package/lib/types/ink/render-node-to-output.js +14 -6
- package/lib/types/ink/screen.d.ts +39 -0
- package/lib/types/ink/screen.d.ts.map +1 -1
- package/lib/types/ink/screen.js +117 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +26 -6
- package/lib/types/ink/wrapAnsi.d.ts +1 -1
- package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
- package/lib/types/ink/wrapAnsi.js +29 -2
- package/lib/types/plugin-host.d.ts +15 -0
- package/lib/types/plugin-host.d.ts.map +1 -0
- package/lib/types/plugin-host.js +17 -0
- package/lib/types/plugin-spec/negotiate.d.ts +11 -0
- package/lib/types/plugin-spec/negotiate.d.ts.map +1 -0
- package/lib/types/plugin-spec/negotiate.js +97 -0
- package/lib/types/plugin-spec/permission-scope.d.ts +32 -0
- package/lib/types/plugin-spec/permission-scope.d.ts.map +1 -0
- package/lib/types/plugin-spec/permission-scope.js +90 -0
- package/lib/types/plugin-spec/registry.d.ts +23 -0
- package/lib/types/plugin-spec/registry.d.ts.map +1 -0
- package/lib/types/plugin-spec/registry.js +252 -0
- package/lib/types/plugin-spec/schema-check.d.ts +17 -0
- package/lib/types/plugin-spec/schema-check.d.ts.map +1 -0
- package/lib/types/plugin-spec/schema-check.js +165 -0
- package/lib/types/plugin-spec/tui-extension.d.ts +16 -0
- package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -0
- package/lib/types/plugin-spec/tui-extension.js +79 -0
- package/lib/types/plugin-spec/types.d.ts +114 -0
- package/lib/types/plugin-spec/types.d.ts.map +1 -0
- package/lib/types/plugin-spec/types.js +10 -0
- package/lib/types/plugin-spec/validate.d.ts +21 -0
- package/lib/types/plugin-spec/validate.d.ts.map +1 -0
- package/lib/types/plugin-spec/validate.js +138 -0
- package/lib/types/scenes.d.ts +2 -1
- package/lib/types/scenes.d.ts.map +1 -1
- package/lib/types/scenes.js +1 -1
- package/lib/types/screens/Chat.d.ts +14 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +173 -49
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +10 -3
- package/lib/types/sessions/view.d.ts +3 -2
- package/lib/types/sessions/view.d.ts.map +1 -1
- package/lib/types/sessions/view.js +18 -0
- package/lib/types/settings-sections.d.ts +2 -1
- package/lib/types/settings-sections.d.ts.map +1 -1
- package/lib/types/settings-sections.js +1 -1
- package/lib/types/theme.d.ts +5 -0
- package/lib/types/theme.d.ts.map +1 -1
- package/lib/types/theme.js +15 -0
- package/lib/types/update.d.ts +20 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +54 -7
- package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
- package/lib/types/utils/execFileNoThrow.js +3 -0
- package/lib/types/utils/loaded-context.d.ts +8 -3
- package/lib/types/utils/loaded-context.d.ts.map +1 -1
- package/lib/types/utils/loaded-context.js +39 -3
- package/lib/types/utils/modifiers.d.ts.map +1 -1
- package/lib/types/utils/modifiers.js +3 -2
- package/lib/types/working-activity.d.ts +12 -0
- package/lib/types/working-activity.d.ts.map +1 -1
- package/lib/types/working-activity.js +13 -0
- package/lib/types/workspaces.d.ts +2 -1
- package/lib/types/workspaces.d.ts.map +1 -1
- package/lib/types/workspaces.js +1 -1
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/command/LICENSE +21 -0
- package/node_modules/@dsh-std/command/README.md +26 -0
- package/node_modules/@dsh-std/command/README.zh.md +28 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts +144 -0
- package/node_modules/@dsh-std/command/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/command/lib/index.js +252 -0
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/command/package.json +22 -0
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/node_modules/@dsh-std/connection/README.md +42 -0
- package/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/node_modules/@dsh-std/connection/package.json +20 -0
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/core/LICENSE +21 -0
- package/node_modules/@dsh-std/core/README.md +13 -0
- package/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/core/package.json +21 -0
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/node_modules/@dsh-std/manifest/README.md +5 -0
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/manifest/package.json +20 -0
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/messages/LICENSE +21 -0
- package/node_modules/@dsh-std/messages/README.md +5 -0
- package/node_modules/@dsh-std/messages/README.zh.md +7 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts +50 -0
- package/node_modules/@dsh-std/messages/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/messages/lib/index.js +151 -0
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/messages/package.json +20 -0
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -0
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/node_modules/@dsh-std/presentation/README.md +27 -0
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/node_modules/@dsh-std/presentation/package.json +25 -0
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
- package/node_modules/@dsh-std/storage/LICENSE +21 -0
- package/node_modules/@dsh-std/storage/README.md +5 -0
- package/node_modules/@dsh-std/storage/README.zh.md +7 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts +48 -0
- package/node_modules/@dsh-std/storage/lib/index.d.ts.map +1 -0
- package/node_modules/@dsh-std/storage/lib/index.js +104 -0
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -0
- package/node_modules/@dsh-std/storage/package.json +20 -0
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -0
- package/package.json +110 -70
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts +182 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js +625 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +262 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +550 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/interaction.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.d.ts +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/operations.js +2 -0
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts +125 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/connection-CdGcSQnu.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts +89 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js +158 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +24 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +258 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js +226 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts +112 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.d.ts.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js +424 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -0
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult } from "./callback.js";
|
|
2
|
+
import { defineCapabilityProtocol } from "@dsh-std/connection";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const API_VERSION = "presentation.dsh/v1alpha1";
|
|
5
|
+
const OPEN_EXTERNAL_KIND = "OpenExternal";
|
|
6
|
+
const COPY_TEXT_KIND = "CopyText";
|
|
7
|
+
const NOTIFICATION_KIND = "Notification";
|
|
8
|
+
const USER_INTERACTION_KIND = "UserInteraction";
|
|
9
|
+
const emptySpec = (value) => {
|
|
10
|
+
if (value !== void 0) throw new TypeError("Presentation operation does not accept spec in v1alpha1");
|
|
11
|
+
};
|
|
12
|
+
const openExternalProtocol = defineCapabilityProtocol({
|
|
13
|
+
apiVersion: API_VERSION,
|
|
14
|
+
kind: OPEN_EXTERNAL_KIND,
|
|
15
|
+
validateRequirement: emptySpec,
|
|
16
|
+
validateSupport: emptySpec
|
|
17
|
+
});
|
|
18
|
+
const copyTextProtocol = defineCapabilityProtocol({
|
|
19
|
+
apiVersion: API_VERSION,
|
|
20
|
+
kind: COPY_TEXT_KIND,
|
|
21
|
+
validateRequirement: emptySpec,
|
|
22
|
+
validateSupport: emptySpec
|
|
23
|
+
});
|
|
24
|
+
const notificationProtocol = defineCapabilityProtocol({
|
|
25
|
+
apiVersion: API_VERSION,
|
|
26
|
+
kind: NOTIFICATION_KIND,
|
|
27
|
+
validateRequirement: emptySpec,
|
|
28
|
+
validateSupport: emptySpec
|
|
29
|
+
});
|
|
30
|
+
const openExternalSupport = Object.freeze({
|
|
31
|
+
apiVersion: API_VERSION,
|
|
32
|
+
kind: OPEN_EXTERNAL_KIND
|
|
33
|
+
});
|
|
34
|
+
const copyTextSupport = Object.freeze({
|
|
35
|
+
apiVersion: API_VERSION,
|
|
36
|
+
kind: COPY_TEXT_KIND
|
|
37
|
+
});
|
|
38
|
+
const notificationSupport = Object.freeze({
|
|
39
|
+
apiVersion: API_VERSION,
|
|
40
|
+
kind: NOTIFICATION_KIND
|
|
41
|
+
});
|
|
42
|
+
const userInteractionSupport = (spec) => Object.freeze({
|
|
43
|
+
apiVersion: API_VERSION,
|
|
44
|
+
kind: USER_INTERACTION_KIND,
|
|
45
|
+
spec: validateUserInteractionSupport(spec)
|
|
46
|
+
});
|
|
47
|
+
const userInteractionProtocol = Object.freeze({
|
|
48
|
+
apiVersion: API_VERSION,
|
|
49
|
+
kind: USER_INTERACTION_KIND,
|
|
50
|
+
validateRequirement: validateUserInteractionRequirement,
|
|
51
|
+
validateSupport: validateUserInteractionSupport,
|
|
52
|
+
negotiate: negotiateUserInteraction
|
|
53
|
+
});
|
|
54
|
+
const protocols = Object.freeze([
|
|
55
|
+
openExternalProtocol,
|
|
56
|
+
copyTextProtocol,
|
|
57
|
+
notificationProtocol,
|
|
58
|
+
userInteractionProtocol,
|
|
59
|
+
externalRedirectProtocol
|
|
60
|
+
]);
|
|
61
|
+
function register(catalog) {
|
|
62
|
+
const disposers = protocols.map((protocol) => catalog.register(protocol));
|
|
63
|
+
return () => {
|
|
64
|
+
for (const dispose of disposers.reverse()) dispose();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function openExternalClient(client, scope) {
|
|
68
|
+
const request = requestFactory(scope);
|
|
69
|
+
return Object.freeze({ async openExternal(input, options) {
|
|
70
|
+
const value = request(input);
|
|
71
|
+
validateOpenExternalRequest(value);
|
|
72
|
+
return validatePresentationResult(await client.invoke(openExternalSupport, "openExternal", value, options).result, validateAcceptedReceipt, "OpenExternal result");
|
|
73
|
+
} });
|
|
74
|
+
}
|
|
75
|
+
function copyTextClient(client, scope) {
|
|
76
|
+
const request = requestFactory(scope);
|
|
77
|
+
return Object.freeze({ async copyText(input, options) {
|
|
78
|
+
const value = request(input);
|
|
79
|
+
validateCopyTextRequest(value);
|
|
80
|
+
return validatePresentationResult(await client.invoke(copyTextSupport, "copyText", value, options).result, validateAcceptedReceipt, "CopyText result");
|
|
81
|
+
} });
|
|
82
|
+
}
|
|
83
|
+
function notificationClient(client, scope) {
|
|
84
|
+
const request = requestFactory(scope);
|
|
85
|
+
return Object.freeze({ async notify(input, options) {
|
|
86
|
+
const value = request(input);
|
|
87
|
+
validateNotificationRequest(value);
|
|
88
|
+
return validatePresentationResult(await client.invoke(notificationSupport, "notify", value, options).result, validateAcceptedReceipt, "Notification result");
|
|
89
|
+
} });
|
|
90
|
+
}
|
|
91
|
+
function userInteractionClient(client, scope) {
|
|
92
|
+
const request = requestFactory(scope);
|
|
93
|
+
return Object.freeze({ async interact(input, options) {
|
|
94
|
+
const value = request(input);
|
|
95
|
+
validateUserInteractionRequest(value);
|
|
96
|
+
return validateInteractionResult(value, await client.invoke({
|
|
97
|
+
apiVersion: API_VERSION,
|
|
98
|
+
kind: USER_INTERACTION_KIND
|
|
99
|
+
}, "interact", value, options).result);
|
|
100
|
+
} });
|
|
101
|
+
}
|
|
102
|
+
function presentationClients(descriptor, client, scope) {
|
|
103
|
+
validatePresentationDescriptor(descriptor);
|
|
104
|
+
validateInvocationScope(scope);
|
|
105
|
+
const has = (kind) => descriptor.contracts.some((contract) => contract.apiVersion === "presentation.dsh/v1alpha1" && contract.kind === kind && client.binding(contract) !== void 0);
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
descriptor: freezeClone(descriptor),
|
|
108
|
+
...has("OpenExternal") ? { openExternal: openExternalClient(client, scope) } : {},
|
|
109
|
+
...has("CopyText") ? { copyText: copyTextClient(client, scope) } : {},
|
|
110
|
+
...has("Notification") ? { notification: notificationClient(client, scope) } : {},
|
|
111
|
+
...has("UserInteraction") ? { interaction: userInteractionClient(client, scope) } : {},
|
|
112
|
+
...has("ExternalRedirect") ? { externalRedirect: externalRedirectClient(client, scope) } : {}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function openExternalImplementation(participantId, handler) {
|
|
116
|
+
return implementation(participantId, openExternalSupport, "openExternal", validateOpenExternalRequest, handler.openExternal.bind(handler), (result) => validatePresentationResult(result, validateAcceptedReceipt, "OpenExternal result"));
|
|
117
|
+
}
|
|
118
|
+
function copyTextImplementation(participantId, handler) {
|
|
119
|
+
return implementation(participantId, copyTextSupport, "copyText", validateCopyTextRequest, handler.copyText.bind(handler), (result) => validatePresentationResult(result, validateAcceptedReceipt, "CopyText result"));
|
|
120
|
+
}
|
|
121
|
+
function notificationImplementation(participantId, handler) {
|
|
122
|
+
return implementation(participantId, notificationSupport, "notify", validateNotificationRequest, handler.notify.bind(handler), (result) => validatePresentationResult(result, validateAcceptedReceipt, "Notification result"));
|
|
123
|
+
}
|
|
124
|
+
function userInteractionImplementation(participantId, spec, handler) {
|
|
125
|
+
const protocol = userInteractionSupport(spec);
|
|
126
|
+
return Object.freeze({
|
|
127
|
+
participantId,
|
|
128
|
+
protocol,
|
|
129
|
+
async handle(operationName, input, context) {
|
|
130
|
+
if (operationName !== "interact") throw new TypeError(`unsupported UserInteraction operation ${JSON.stringify(operationName)}`);
|
|
131
|
+
validateUserInteractionRequest(input);
|
|
132
|
+
if (!spec.operations.includes(input.kind)) throw new TypeError(`UserInteraction provider does not support ${JSON.stringify(input.kind)}`);
|
|
133
|
+
return validateInteractionResult(input, await handler.interact(input, context));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function validatePresentationDescriptor(value) {
|
|
138
|
+
const descriptor = exactRecord(value, ["clientId", "contracts"], ["clientId", "contracts"], "Presentation descriptor");
|
|
139
|
+
nonEmpty(descriptor.clientId, "Presentation descriptor.clientId");
|
|
140
|
+
if (!Array.isArray(descriptor.contracts)) throw new TypeError("Presentation descriptor.contracts must be an array");
|
|
141
|
+
const seen = /* @__PURE__ */ new Set();
|
|
142
|
+
for (const [index, contractValue] of descriptor.contracts.entries()) {
|
|
143
|
+
const contract = exactRecord(contractValue, [
|
|
144
|
+
"apiVersion",
|
|
145
|
+
"kind",
|
|
146
|
+
"spec"
|
|
147
|
+
], ["apiVersion", "kind"], `Presentation descriptor.contracts[${index}]`);
|
|
148
|
+
nonEmpty(contract.apiVersion, `Presentation descriptor.contracts[${index}].apiVersion`);
|
|
149
|
+
nonEmpty(contract.kind, `Presentation descriptor.contracts[${index}].kind`);
|
|
150
|
+
const key = `${String(contract.apiVersion)}\0${String(contract.kind)}`;
|
|
151
|
+
if (seen.has(key)) throw new TypeError(`Presentation descriptor contains duplicate contract ${JSON.stringify(key)}`);
|
|
152
|
+
seen.add(key);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function validateOpenExternalRequest(value) {
|
|
156
|
+
const request = requestRecord(value, ["uri"], "OpenExternal request");
|
|
157
|
+
nonEmpty(request.uri, "OpenExternal request.uri");
|
|
158
|
+
const uri = new URL(request.uri);
|
|
159
|
+
if (uri.protocol !== "https:" && uri.protocol !== "http:") throw new TypeError("OpenExternal only accepts HTTP(S) URIs");
|
|
160
|
+
}
|
|
161
|
+
function validateCopyTextRequest(value) {
|
|
162
|
+
const request = requestRecord(value, ["text", "sensitivity"], "CopyText request");
|
|
163
|
+
nonEmpty(request.text, "CopyText request.text");
|
|
164
|
+
if (request.sensitivity !== void 0 && request.sensitivity !== "public" && request.sensitivity !== "private") throw new TypeError("CopyText request.sensitivity is invalid");
|
|
165
|
+
}
|
|
166
|
+
function validateNotificationRequest(value) {
|
|
167
|
+
const request = requestRecord(value, [
|
|
168
|
+
"text",
|
|
169
|
+
"level",
|
|
170
|
+
"deduplicationKey"
|
|
171
|
+
], "Notification request");
|
|
172
|
+
nonEmpty(request.text, "Notification request.text");
|
|
173
|
+
if (request.level !== void 0 && request.level !== "info" && request.level !== "warning" && request.level !== "error") throw new TypeError("Notification request.level is invalid");
|
|
174
|
+
if (request.deduplicationKey !== void 0) nonEmpty(request.deduplicationKey, "Notification request.deduplicationKey");
|
|
175
|
+
}
|
|
176
|
+
function validateUserInteractionRequest(value) {
|
|
177
|
+
if (!record(value)) throw new TypeError("UserInteraction request must be an object");
|
|
178
|
+
if (value.kind === "question") return validateQuestionRequest(value);
|
|
179
|
+
if (value.kind === "approval") return validateApprovalRequest(value);
|
|
180
|
+
if (value.kind === "secret-input") return validateSecretInputRequest(value);
|
|
181
|
+
throw new TypeError("UserInteraction request.kind is invalid");
|
|
182
|
+
}
|
|
183
|
+
function validateUserInteractionRequirement(value) {
|
|
184
|
+
const spec = exactRecord(value, ["operations", "optionalOperations"], ["operations"], "UserInteraction requirement spec");
|
|
185
|
+
const operations = operationList(spec.operations, "UserInteraction requirement spec.operations");
|
|
186
|
+
const optionalOperations = spec.optionalOperations === void 0 ? void 0 : operationList(spec.optionalOperations, "UserInteraction requirement spec.optionalOperations");
|
|
187
|
+
if (optionalOperations?.some((operation) => operations.includes(operation)) === true) throw new TypeError("UserInteraction optionalOperations must not duplicate required operations");
|
|
188
|
+
return deepFreeze({
|
|
189
|
+
operations,
|
|
190
|
+
...optionalOperations === void 0 ? {} : { optionalOperations }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function validateUserInteractionSupport(value) {
|
|
194
|
+
const spec = exactRecord(value, ["operations", "limits"], ["operations"], "UserInteraction support spec");
|
|
195
|
+
const operations = operationList(spec.operations, "UserInteraction support spec.operations");
|
|
196
|
+
const limits = spec.limits === void 0 ? void 0 : validateLimits(spec.limits);
|
|
197
|
+
return deepFreeze({
|
|
198
|
+
operations,
|
|
199
|
+
...limits === void 0 ? {} : { limits }
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function negotiateUserInteraction(input) {
|
|
203
|
+
const issues = [];
|
|
204
|
+
const bindings = [];
|
|
205
|
+
const connectionPolicy = connectionNegotiationPolicy(input.policy);
|
|
206
|
+
for (const row of input.requirements) {
|
|
207
|
+
const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant];
|
|
208
|
+
const candidates = input.supports.filter((candidate) => {
|
|
209
|
+
if (candidate.participant === row.participant) return false;
|
|
210
|
+
if (consumerEndpoint !== void 0 && connectionPolicy?.endpointByParticipant[candidate.participant] === consumerEndpoint) return false;
|
|
211
|
+
return row.requirement.spec.operations.every((operation) => candidate.support.spec.operations.includes(operation));
|
|
212
|
+
});
|
|
213
|
+
if (candidates.length === 0) {
|
|
214
|
+
issues.push(Object.freeze({
|
|
215
|
+
code: row.requirement.optional === true ? "optional-support-missing" : "required-support-missing",
|
|
216
|
+
severity: row.requirement.optional === true ? "warning" : "error",
|
|
217
|
+
participant: row.participant,
|
|
218
|
+
message: `no participant supports the required ${USER_INTERACTION_KIND} operations`
|
|
219
|
+
}));
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (candidates.length > 1) {
|
|
223
|
+
issues.push(Object.freeze({
|
|
224
|
+
code: "support-ambiguous",
|
|
225
|
+
severity: "error",
|
|
226
|
+
participant: row.participant,
|
|
227
|
+
message: `multiple participants support ${API_VERSION} ${USER_INTERACTION_KIND}`
|
|
228
|
+
}));
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const provider = candidates[0];
|
|
232
|
+
bindings.push(Object.freeze({
|
|
233
|
+
consumer: row.participant,
|
|
234
|
+
provider: provider.participant,
|
|
235
|
+
requirement: row.requirement,
|
|
236
|
+
support: provider.support
|
|
237
|
+
}));
|
|
238
|
+
for (const operation of row.requirement.spec.optionalOperations ?? []) {
|
|
239
|
+
if (provider.support.spec.operations.includes(operation)) continue;
|
|
240
|
+
issues.push(Object.freeze({
|
|
241
|
+
code: "optional-operation-missing",
|
|
242
|
+
severity: "warning",
|
|
243
|
+
participant: row.participant,
|
|
244
|
+
message: `${USER_INTERACTION_KIND} provider does not support optional operation ${JSON.stringify(operation)}`
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
agreement: Object.freeze({
|
|
250
|
+
kind: "CapabilityBindings",
|
|
251
|
+
bindings: Object.freeze(bindings)
|
|
252
|
+
}),
|
|
253
|
+
issues: Object.freeze(issues)
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function connectionNegotiationPolicy(value) {
|
|
257
|
+
return record(value) && record(value.endpointByParticipant) ? value : void 0;
|
|
258
|
+
}
|
|
259
|
+
function implementation(participantId, protocol, operationName, validateInput, handler, validateOutput) {
|
|
260
|
+
return Object.freeze({
|
|
261
|
+
participantId,
|
|
262
|
+
protocol,
|
|
263
|
+
async handle(operation, input, context) {
|
|
264
|
+
if (operation !== operationName) throw new TypeError(`unsupported ${protocol.kind} operation ${JSON.stringify(operation)}`);
|
|
265
|
+
validateInput(input);
|
|
266
|
+
return validateOutput(await handler(input, context));
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function validateQuestionRequest(value) {
|
|
271
|
+
const request = requestRecord(value, [
|
|
272
|
+
"kind",
|
|
273
|
+
"title",
|
|
274
|
+
"description",
|
|
275
|
+
"fields"
|
|
276
|
+
], "Question request");
|
|
277
|
+
if (request.kind !== "question") throw new TypeError("Question request.kind must be \"question\"");
|
|
278
|
+
optionalText(request.title, "Question request.title");
|
|
279
|
+
optionalText(request.description, "Question request.description");
|
|
280
|
+
if (!Array.isArray(request.fields) || request.fields.length === 0) throw new TypeError("Question request.fields must be a non-empty array");
|
|
281
|
+
const ids = /* @__PURE__ */ new Set();
|
|
282
|
+
for (const [index, fieldValue] of request.fields.entries()) {
|
|
283
|
+
const label = `Question request.fields[${index}]`;
|
|
284
|
+
if (!record(fieldValue)) throw new TypeError(`${label} must be an object`);
|
|
285
|
+
const common = [
|
|
286
|
+
"id",
|
|
287
|
+
"kind",
|
|
288
|
+
"label",
|
|
289
|
+
"description",
|
|
290
|
+
"required"
|
|
291
|
+
];
|
|
292
|
+
const field = exactRecord(fieldValue, fieldValue.kind === "text" ? [
|
|
293
|
+
...common,
|
|
294
|
+
"multiline",
|
|
295
|
+
"minLength",
|
|
296
|
+
"maxLength"
|
|
297
|
+
] : fieldValue.kind === "select" ? [
|
|
298
|
+
...common,
|
|
299
|
+
"multiple",
|
|
300
|
+
"options"
|
|
301
|
+
] : common, [
|
|
302
|
+
"id",
|
|
303
|
+
"kind",
|
|
304
|
+
"label"
|
|
305
|
+
], label);
|
|
306
|
+
localId(field.id, `${label}.id`);
|
|
307
|
+
if (ids.has(field.id)) throw new TypeError("Question request contains duplicate field id");
|
|
308
|
+
ids.add(field.id);
|
|
309
|
+
nonEmpty(field.label, `${label}.label`);
|
|
310
|
+
optionalText(field.description, `${label}.description`);
|
|
311
|
+
optionalBoolean(field.required, `${label}.required`);
|
|
312
|
+
if (field.kind === "text") {
|
|
313
|
+
optionalBoolean(field.multiline, `${label}.multiline`);
|
|
314
|
+
lengthBounds(field.minLength, field.maxLength, label);
|
|
315
|
+
} else if (field.kind === "select") {
|
|
316
|
+
optionalBoolean(field.multiple, `${label}.multiple`);
|
|
317
|
+
if (!Array.isArray(field.options) || field.options.length === 0) throw new TypeError(`${label}.options must be a non-empty array`);
|
|
318
|
+
const options = /* @__PURE__ */ new Set();
|
|
319
|
+
for (const [optionIndex, optionValue] of field.options.entries()) {
|
|
320
|
+
const optionLabel = `${label}.options[${optionIndex}]`;
|
|
321
|
+
const option = exactRecord(optionValue, [
|
|
322
|
+
"id",
|
|
323
|
+
"label",
|
|
324
|
+
"description"
|
|
325
|
+
], ["id", "label"], optionLabel);
|
|
326
|
+
localId(option.id, `${optionLabel}.id`);
|
|
327
|
+
if (options.has(option.id)) throw new TypeError(`${label} contains duplicate option id`);
|
|
328
|
+
options.add(option.id);
|
|
329
|
+
nonEmpty(option.label, `${optionLabel}.label`);
|
|
330
|
+
optionalText(option.description, `${optionLabel}.description`);
|
|
331
|
+
}
|
|
332
|
+
} else if (field.kind !== "confirm") throw new TypeError(`${label}.kind is invalid`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function validateApprovalRequest(value) {
|
|
336
|
+
const request = requestRecord(value, [
|
|
337
|
+
"kind",
|
|
338
|
+
"action",
|
|
339
|
+
"summary",
|
|
340
|
+
"details",
|
|
341
|
+
"risk"
|
|
342
|
+
], "Approval request");
|
|
343
|
+
if (request.kind !== "approval") throw new TypeError("Approval request.kind must be \"approval\"");
|
|
344
|
+
nonEmpty(request.action, "Approval request.action");
|
|
345
|
+
nonEmpty(request.summary, "Approval request.summary");
|
|
346
|
+
if (request.risk !== void 0 && request.risk !== "low" && request.risk !== "medium" && request.risk !== "high") throw new TypeError("Approval request.risk is invalid");
|
|
347
|
+
if (request.details !== void 0) {
|
|
348
|
+
if (!Array.isArray(request.details)) throw new TypeError("Approval request.details must be an array");
|
|
349
|
+
for (const [index, detailValue] of request.details.entries()) {
|
|
350
|
+
const label = `Approval request.details[${index}]`;
|
|
351
|
+
const detail = exactRecord(detailValue, [
|
|
352
|
+
"label",
|
|
353
|
+
"value",
|
|
354
|
+
"sensitivity"
|
|
355
|
+
], ["label", "value"], label);
|
|
356
|
+
nonEmpty(detail.label, `${label}.label`);
|
|
357
|
+
nonEmpty(detail.value, `${label}.value`);
|
|
358
|
+
if (detail.sensitivity !== void 0 && detail.sensitivity !== "public" && detail.sensitivity !== "private") throw new TypeError(`${label}.sensitivity is invalid`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function validateSecretInputRequest(value) {
|
|
363
|
+
const request = requestRecord(value, [
|
|
364
|
+
"kind",
|
|
365
|
+
"label",
|
|
366
|
+
"description",
|
|
367
|
+
"minLength",
|
|
368
|
+
"maxLength"
|
|
369
|
+
], "SecretInput request");
|
|
370
|
+
if (request.kind !== "secret-input") throw new TypeError("SecretInput request.kind must be \"secret-input\"");
|
|
371
|
+
nonEmpty(request.label, "SecretInput request.label");
|
|
372
|
+
optionalText(request.description, "SecretInput request.description");
|
|
373
|
+
lengthBounds(request.minLength, request.maxLength, "SecretInput request");
|
|
374
|
+
}
|
|
375
|
+
function validateInteractionResult(request, value) {
|
|
376
|
+
if (request.kind === "question") return validatePresentationResult(value, (result) => validateQuestionAnswers(request, result), "Question result");
|
|
377
|
+
if (request.kind === "approval") return validatePresentationResult(value, validateApprovalValue, "Approval result");
|
|
378
|
+
return validatePresentationResult(value, (result) => validateSecretInputValue(request, result), "SecretInput result");
|
|
379
|
+
}
|
|
380
|
+
function validateQuestionAnswers(request, value) {
|
|
381
|
+
const result = exactRecord(value, ["answers"], ["answers"], "Question answers");
|
|
382
|
+
if (!record(result.answers)) throw new TypeError("Question answers.answers must be an object");
|
|
383
|
+
const fields = new Map(request.fields.map((field) => [field.id, field]));
|
|
384
|
+
for (const field of request.fields) if (field.required === true && !Object.hasOwn(result.answers, field.id)) throw new TypeError(`Question answers is missing required field ${JSON.stringify(field.id)}`);
|
|
385
|
+
for (const [id, answer] of Object.entries(result.answers)) {
|
|
386
|
+
const field = fields.get(id);
|
|
387
|
+
if (field === void 0) throw new TypeError(`Question answers contains unknown field ${JSON.stringify(id)}`);
|
|
388
|
+
if (field.kind === "text") {
|
|
389
|
+
if (typeof answer !== "string") throw new TypeError(`Question answer ${JSON.stringify(id)} must be a string`);
|
|
390
|
+
if (field.minLength !== void 0 && answer.length < field.minLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too short`);
|
|
391
|
+
if (field.maxLength !== void 0 && answer.length > field.maxLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too long`);
|
|
392
|
+
} else if (field.kind === "confirm") {
|
|
393
|
+
if (typeof answer !== "boolean") throw new TypeError(`Question answer ${JSON.stringify(id)} must be boolean`);
|
|
394
|
+
} else {
|
|
395
|
+
const allowed = new Set(field.options.map((option) => option.id));
|
|
396
|
+
const selected = field.multiple === true ? answer : [answer];
|
|
397
|
+
if (!Array.isArray(selected) || selected.some((option) => typeof option !== "string" || !allowed.has(option))) throw new TypeError(`Question answer ${JSON.stringify(id)} contains an invalid option`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return freezeClone(value);
|
|
401
|
+
}
|
|
402
|
+
function validateApprovalValue(value) {
|
|
403
|
+
const result = exactRecord(value, ["decision"], ["decision"], "Approval value");
|
|
404
|
+
if (result.decision !== "approved" && result.decision !== "denied") throw new TypeError("Approval value.decision is invalid");
|
|
405
|
+
return freezeClone(value);
|
|
406
|
+
}
|
|
407
|
+
function validateSecretInputValue(request, value) {
|
|
408
|
+
const result = exactRecord(value, ["secret"], ["secret"], "SecretInput value");
|
|
409
|
+
if (typeof result.secret !== "string") throw new TypeError("SecretInput value.secret must be a string");
|
|
410
|
+
if (request.minLength !== void 0 && result.secret.length < request.minLength) throw new TypeError("SecretInput value.secret is too short");
|
|
411
|
+
if (request.maxLength !== void 0 && result.secret.length > request.maxLength) throw new TypeError("SecretInput value.secret is too long");
|
|
412
|
+
return freezeClone(value);
|
|
413
|
+
}
|
|
414
|
+
function validatePresentationResult(value, validateSubmitted, label) {
|
|
415
|
+
if (!record(value)) throw new TypeError(`${label} must be an object`);
|
|
416
|
+
if (value.status === "submitted") return deepFreeze({
|
|
417
|
+
status: "submitted",
|
|
418
|
+
value: validateSubmitted(exactRecord(value, ["status", "value"], ["status", "value"], label).value)
|
|
419
|
+
});
|
|
420
|
+
if (value.status === "unavailable") {
|
|
421
|
+
optionalText(exactRecord(value, ["status", "reason"], ["status"], label).reason, `${label}.reason`);
|
|
422
|
+
return freezeClone(value);
|
|
423
|
+
}
|
|
424
|
+
if (value.status === "cancelled" || value.status === "expired") {
|
|
425
|
+
exactRecord(value, ["status"], ["status"], label);
|
|
426
|
+
return freezeClone(value);
|
|
427
|
+
}
|
|
428
|
+
throw new TypeError(`${label}.status is invalid`);
|
|
429
|
+
}
|
|
430
|
+
function validateAcceptedReceipt(value) {
|
|
431
|
+
if (exactRecord(value, ["accepted"], ["accepted"], "Presentation receipt").accepted !== true) throw new TypeError("Presentation receipt.accepted must be true");
|
|
432
|
+
return Object.freeze({ accepted: true });
|
|
433
|
+
}
|
|
434
|
+
function requestRecord(value, fields, label) {
|
|
435
|
+
const required = [
|
|
436
|
+
"requestId",
|
|
437
|
+
"invocationId",
|
|
438
|
+
"origin",
|
|
439
|
+
...fields.filter((field) => ![
|
|
440
|
+
"title",
|
|
441
|
+
"description",
|
|
442
|
+
"details",
|
|
443
|
+
"risk",
|
|
444
|
+
"level",
|
|
445
|
+
"deduplicationKey",
|
|
446
|
+
"sensitivity",
|
|
447
|
+
"minLength",
|
|
448
|
+
"maxLength"
|
|
449
|
+
].includes(field))
|
|
450
|
+
];
|
|
451
|
+
const request = exactRecord(value, [
|
|
452
|
+
"requestId",
|
|
453
|
+
"invocationId",
|
|
454
|
+
"origin",
|
|
455
|
+
"deadline",
|
|
456
|
+
...fields
|
|
457
|
+
], required, label);
|
|
458
|
+
nonEmpty(request.requestId, `${label}.requestId`);
|
|
459
|
+
nonEmpty(request.invocationId, `${label}.invocationId`);
|
|
460
|
+
nonEmpty(request.origin, `${label}.origin`);
|
|
461
|
+
if (request.deadline !== void 0 && (typeof request.deadline !== "string" || Number.isNaN(Date.parse(request.deadline)))) throw new TypeError(`${label}.deadline must be an RFC 3339 date-time`);
|
|
462
|
+
return request;
|
|
463
|
+
}
|
|
464
|
+
function validateLimits(value) {
|
|
465
|
+
const limits = exactRecord(value, [
|
|
466
|
+
"maxConcurrentRequests",
|
|
467
|
+
"maxFields",
|
|
468
|
+
"maxOptionsPerField",
|
|
469
|
+
"maxTextLength"
|
|
470
|
+
], [], "UserInteraction limits");
|
|
471
|
+
for (const [name, limit] of Object.entries(limits)) positiveInteger(limit, `UserInteraction limits.${name}`);
|
|
472
|
+
return freezeClone(value);
|
|
473
|
+
}
|
|
474
|
+
function operationList(value, label) {
|
|
475
|
+
if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`);
|
|
476
|
+
const operations = value.map((operation) => {
|
|
477
|
+
if (operation !== "question" && operation !== "approval" && operation !== "secret-input") throw new TypeError(`${label} contains an invalid operation`);
|
|
478
|
+
return operation;
|
|
479
|
+
});
|
|
480
|
+
if (new Set(operations).size !== operations.length) throw new TypeError(`${label} contains a duplicate operation`);
|
|
481
|
+
return Object.freeze(operations);
|
|
482
|
+
}
|
|
483
|
+
function lengthBounds(minimum, maximum, label) {
|
|
484
|
+
if (minimum !== void 0) nonNegativeInteger(minimum, `${label}.minLength`);
|
|
485
|
+
if (maximum !== void 0) nonNegativeInteger(maximum, `${label}.maxLength`);
|
|
486
|
+
if (typeof minimum === "number" && typeof maximum === "number" && minimum > maximum) throw new TypeError(`${label}.minLength must not exceed maxLength`);
|
|
487
|
+
}
|
|
488
|
+
function exactRecord(value, allowed, required, label) {
|
|
489
|
+
if (!record(value)) throw new TypeError(`${label} must be an object`);
|
|
490
|
+
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
|
|
491
|
+
if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`);
|
|
492
|
+
for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`);
|
|
493
|
+
return value;
|
|
494
|
+
}
|
|
495
|
+
function record(value) {
|
|
496
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
497
|
+
}
|
|
498
|
+
function nonEmpty(value, label) {
|
|
499
|
+
if (typeof value !== "string" || value.trim() === "") throw new TypeError(`${label} must be a non-empty string`);
|
|
500
|
+
}
|
|
501
|
+
function validateInvocationScope(scope) {
|
|
502
|
+
if (!record(scope)) throw new TypeError("Presentation invocation scope must be an object");
|
|
503
|
+
nonEmpty(scope.invocationId, "Presentation invocation scope.invocationId");
|
|
504
|
+
nonEmpty(scope.origin, "Presentation invocation scope.origin");
|
|
505
|
+
if (scope.deadline !== void 0 && (typeof scope.deadline !== "string" || Number.isNaN(Date.parse(scope.deadline)))) throw new TypeError("Presentation invocation scope.deadline must be an RFC 3339 date-time");
|
|
506
|
+
if (typeof scope.nextRequestId !== "function") throw new TypeError("Presentation invocation scope.nextRequestId must be a function");
|
|
507
|
+
}
|
|
508
|
+
function requestFactory(scope) {
|
|
509
|
+
validateInvocationScope(scope);
|
|
510
|
+
return (input) => {
|
|
511
|
+
if (!record(input)) throw new TypeError("Presentation input must be an object");
|
|
512
|
+
const requestId = scope.nextRequestId();
|
|
513
|
+
nonEmpty(requestId, "Presentation requestId");
|
|
514
|
+
return freezeClone({
|
|
515
|
+
...input,
|
|
516
|
+
requestId,
|
|
517
|
+
invocationId: scope.invocationId,
|
|
518
|
+
origin: scope.origin,
|
|
519
|
+
...scope.deadline === void 0 ? {} : { deadline: scope.deadline }
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function optionalText(value, label) {
|
|
524
|
+
if (value !== void 0) nonEmpty(value, label);
|
|
525
|
+
}
|
|
526
|
+
function optionalBoolean(value, label) {
|
|
527
|
+
if (value !== void 0 && typeof value !== "boolean") throw new TypeError(`${label} must be boolean`);
|
|
528
|
+
}
|
|
529
|
+
function localId(value, label) {
|
|
530
|
+
if (typeof value !== "string" || !/^[A-Za-z][A-Za-z0-9._-]*$/u.test(value)) throw new TypeError(`${label} is invalid`);
|
|
531
|
+
}
|
|
532
|
+
function positiveInteger(value, label) {
|
|
533
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${label} must be a positive safe integer`);
|
|
534
|
+
}
|
|
535
|
+
function nonNegativeInteger(value, label) {
|
|
536
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${label} must be a non-negative safe integer`);
|
|
537
|
+
}
|
|
538
|
+
function freezeClone(value) {
|
|
539
|
+
return deepFreeze(structuredClone(value));
|
|
540
|
+
}
|
|
541
|
+
function deepFreeze(value) {
|
|
542
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
543
|
+
Object.freeze(value);
|
|
544
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
545
|
+
return value;
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
export { API_VERSION, COPY_TEXT_KIND, EXTERNAL_REDIRECT_KIND, NOTIFICATION_KIND, OPEN_EXTERNAL_KIND, USER_INTERACTION_KIND, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport };
|
|
549
|
+
|
|
550
|
+
//# sourceMappingURL=index.js.map
|