@deepseek-harness-tui/dsh-tui 0.9.1 → 0.9.3
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 +14 -4
- package/bin/dsh-tui.js +26 -4
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
- package/dsh-ecosystem-spec/registry/README.md +14 -14
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +7 -8
- package/lib/types/components/BalanceReportRow.d.ts +24 -0
- package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
- package/lib/types/components/BalanceReportRow.js +87 -0
- package/lib/types/components/HistorySearchDialog.js +1 -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 +11 -7
- package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
- package/lib/types/components/PluginSceneBoundary.js +1 -1
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +16 -0
- package/lib/types/components/Whale.d.ts +15 -4
- package/lib/types/components/Whale.d.ts.map +1 -1
- package/lib/types/components/Whale.js +9 -8
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
- package/lib/types/deepseekBalance.d.ts +53 -0
- package/lib/types/deepseekBalance.d.ts.map +1 -0
- package/lib/types/deepseekBalance.js +86 -0
- package/lib/types/deepseekPricing.d.ts +82 -0
- package/lib/types/deepseekPricing.d.ts.map +1 -0
- package/lib/types/deepseekPricing.js +133 -0
- package/lib/types/dsh-adapter/channel.d.ts +46 -1
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +84 -10
- package/lib/types/dsh-adapter/index.d.ts +5 -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/packaged-skills.d.ts +9 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
- package/lib/types/dsh-adapter/packaged-skills.js +19 -4
- package/lib/types/dsh-adapter/plugin.d.ts +6 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +122 -18
- package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +35 -2
- package/lib/types/history.d.ts +4 -3
- package/lib/types/history.d.ts.map +1 -1
- package/lib/types/history.js +66 -18
- package/lib/types/i18n.d.ts +122 -55
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +39 -18
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +67 -17
- package/lib/types/ink/root.d.ts +16 -0
- package/lib/types/ink/root.d.ts.map +1 -1
- package/lib/types/ink/root.js +2 -0
- package/lib/types/ink/terminal-querier.d.ts +8 -0
- package/lib/types/ink/terminal-querier.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.js +13 -0
- package/lib/types/ink/terminal.d.ts +42 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +52 -2
- package/lib/types/plugin-spec/registry.d.ts +1 -1
- package/lib/types/plugin-spec/registry.js +1 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +72 -37
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +28 -13
- package/lib/types/screens/SessionTree.d.ts.map +1 -1
- package/lib/types/screens/SessionTree.js +33 -9
- package/lib/types/screens/Settings.d.ts +7 -5
- package/lib/types/screens/Settings.d.ts.map +1 -1
- package/lib/types/screens/Settings.js +206 -99
- package/lib/types/screens/StatusLine.d.ts.map +1 -1
- package/lib/types/screens/StatusLine.js +32 -1
- package/lib/types/sessionHistory.d.ts +11 -0
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +29 -0
- package/lib/types/sessions/format.d.ts.map +1 -1
- package/lib/types/sessions/format.js +14 -4
- package/lib/types/tips.js +2 -2
- package/lib/types/tuiDisplayPrefs.d.ts +3 -0
- package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
- package/lib/types/tuiDisplayPrefs.js +1 -0
- package/lib/types/update.d.ts +66 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +346 -3
- package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
- package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/command/LICENSE +21 -21
- package/node_modules/@dsh-std/command/README.md +26 -26
- package/node_modules/@dsh-std/command/README.zh.md +28 -28
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/command/package.json +22 -22
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/node_modules/@dsh-std/connection/README.md +42 -42
- package/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/node_modules/@dsh-std/connection/package.json +20 -20
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/core/LICENSE +21 -21
- package/node_modules/@dsh-std/core/README.md +13 -13
- package/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/core/package.json +21 -21
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/node_modules/@dsh-std/manifest/README.md +5 -5
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/manifest/package.json +20 -20
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/messages/LICENSE +21 -21
- package/node_modules/@dsh-std/messages/README.md +5 -5
- package/node_modules/@dsh-std/messages/README.zh.md +7 -7
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/messages/package.json +20 -20
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/node_modules/@dsh-std/presentation/README.md +27 -27
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/presentation/package.json +25 -25
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/storage/LICENSE +21 -21
- package/node_modules/@dsh-std/storage/README.md +5 -5
- package/node_modules/@dsh-std/storage/README.zh.md +7 -7
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/storage/package.json +20 -20
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
- package/package.json +95 -5
- package/skills/pr-comments/SKILL.md +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -21
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# @dsh-std/presentation
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh.md)
|
|
4
|
-
|
|
5
|
-
Small, invocation-scoped operations that a runtime facet may request from a connected presentation client.
|
|
6
|
-
|
|
7
|
-
## Contracts
|
|
8
|
-
|
|
9
|
-
`v1alpha1` defines five independent presentation protocols:
|
|
10
|
-
|
|
11
|
-
- `OpenExternal` asks the client to open an HTTP or HTTPS URI.
|
|
12
|
-
- `CopyText` asks the client to copy text to its clipboard.
|
|
13
|
-
- `Notification` asks the client to display informational, warning, or error text.
|
|
14
|
-
- `UserInteraction` carries structured questions, one-invocation approvals, and secret input.
|
|
15
|
-
- `ExternalRedirect` receives a one-shot HTTP redirect on the user side and may reserve an exact loopback URI requested by the consumer.
|
|
16
|
-
|
|
17
|
-
A facet declares each required operation in its manifest. A client advertises only the protocols it can perform for the current connection. The runtime admits the command only when all required presentation protocols are available, and it accepts only operations declared by that facet. Operations belong to the active invocation; they are not a global event bus or a persistent client capability.
|
|
18
|
-
|
|
19
|
-
The package provides protocol definitions, invocation-scoped typed client and implementation binders, and request/result validation. The Host binds request identity and origin when it creates a client; consumers supply only operation-specific input. It does not perform UI work. Native applications, terminals, browsers, editors, and automation clients may implement different subsets.
|
|
20
|
-
|
|
21
|
-
Simple operations are available from `@dsh-std/presentation/operations`, while interaction types are available from `@dsh-std/presentation/interaction`. A Host-provided `PresentationDescriptor` is only a projection of active agreements for the current invocation; it is not a separate Snapshot protocol.
|
|
22
|
-
|
|
23
|
-
## Known Limitations and Deferred Work
|
|
24
|
-
|
|
25
|
-
- `OpenExternal` intentionally rejects non-HTTP(S) URI schemes.
|
|
26
|
-
- Clipboard reads, arbitrary UI trees, and file pickers are not defined.
|
|
27
|
-
- Delivery acknowledgement and durable replay are outside `v1alpha1`.
|
|
1
|
+
# @dsh-std/presentation
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Small, invocation-scoped operations that a runtime facet may request from a connected presentation client.
|
|
6
|
+
|
|
7
|
+
## Contracts
|
|
8
|
+
|
|
9
|
+
`v1alpha1` defines five independent presentation protocols:
|
|
10
|
+
|
|
11
|
+
- `OpenExternal` asks the client to open an HTTP or HTTPS URI.
|
|
12
|
+
- `CopyText` asks the client to copy text to its clipboard.
|
|
13
|
+
- `Notification` asks the client to display informational, warning, or error text.
|
|
14
|
+
- `UserInteraction` carries structured questions, one-invocation approvals, and secret input.
|
|
15
|
+
- `ExternalRedirect` receives a one-shot HTTP redirect on the user side and may reserve an exact loopback URI requested by the consumer.
|
|
16
|
+
|
|
17
|
+
A facet declares each required operation in its manifest. A client advertises only the protocols it can perform for the current connection. The runtime admits the command only when all required presentation protocols are available, and it accepts only operations declared by that facet. Operations belong to the active invocation; they are not a global event bus or a persistent client capability.
|
|
18
|
+
|
|
19
|
+
The package provides protocol definitions, invocation-scoped typed client and implementation binders, and request/result validation. The Host binds request identity and origin when it creates a client; consumers supply only operation-specific input. It does not perform UI work. Native applications, terminals, browsers, editors, and automation clients may implement different subsets.
|
|
20
|
+
|
|
21
|
+
Simple operations are available from `@dsh-std/presentation/operations`, while interaction types are available from `@dsh-std/presentation/interaction`. A Host-provided `PresentationDescriptor` is only a projection of active agreements for the current invocation; it is not a separate Snapshot protocol.
|
|
22
|
+
|
|
23
|
+
## Known Limitations and Deferred Work
|
|
24
|
+
|
|
25
|
+
- `OpenExternal` intentionally rejects non-HTTP(S) URI schemes.
|
|
26
|
+
- Clipboard reads, arbitrary UI trees, and file pickers are not defined.
|
|
27
|
+
- Delivery acknowledgement and durable replay are outside `v1alpha1`.
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# @dsh-std/presentation
|
|
2
|
-
|
|
3
|
-
[English](README.md) | 中文
|
|
4
|
-
|
|
5
|
-
拟议设计见 [Presentation Operations](../../docs/proposals/presentation.zh.md)。
|
|
6
|
-
|
|
7
|
-
运行时插件可以向已连接表现客户端请求的小型、调用作用域内操作。
|
|
8
|
-
|
|
9
|
-
## 协议
|
|
10
|
-
|
|
11
|
-
`v1alpha1` 定义五个彼此独立的表现协议:
|
|
12
|
-
|
|
13
|
-
- `OpenExternal` 请求客户端打开 HTTP 或 HTTPS URI;
|
|
14
|
-
- `CopyText` 请求客户端把文本复制到剪贴板;
|
|
15
|
-
- `Notification` 请求客户端显示信息、警告或错误文本;
|
|
16
|
-
- `UserInteraction` 承载结构化 question、单次 approval 和 secret input。
|
|
17
|
-
- `ExternalRedirect` 在用户侧接收一次 HTTP redirect,并可按调用方要求独占精确的 loopback URI。
|
|
18
|
-
|
|
19
|
-
Facet 在清单中声明每项所需操作。客户端只为当前连接声明自己能够执行的协议。仅当全部必需表现协议可用时,运行时才接纳命令;运行时也只接受该 facet 事先声明的操作。操作属于当前调用,不是全局事件总线或持久客户端能力。
|
|
20
|
-
|
|
21
|
-
本包提供 protocol definitions、调用作用域内的类型化 client/implementation binder、请求与结果校验。Host 创建 client 时绑定 request identity 与 origin,Consumer 只提交 operation 自有输入。它不执行 UI 工作;原生应用、终端、浏览器、编辑器和自动化客户端可以实现不同子集。
|
|
22
|
-
|
|
23
|
-
普通操作可以从 `@dsh-std/presentation/operations` 导入,交互协议可以从 `@dsh-std/presentation/interaction` 导入。Host 交给领域调用的 `PresentationDescriptor` 只是当前 invocation active agreements 的投影,不是额外的 Snapshot 协议。
|
|
24
|
-
|
|
25
|
-
## 已知限制与暂缓事项
|
|
26
|
-
|
|
27
|
-
- `OpenExternal` 有意拒绝非 HTTP(S) URI scheme。
|
|
28
|
-
- 协议不定义剪贴板读取、任意 UI tree 或文件选择器。
|
|
29
|
-
- `v1alpha1` 不包含投递确认与持久回放。
|
|
1
|
+
# @dsh-std/presentation
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
拟议设计见 [Presentation Operations](../../docs/proposals/presentation.zh.md)。
|
|
6
|
+
|
|
7
|
+
运行时插件可以向已连接表现客户端请求的小型、调用作用域内操作。
|
|
8
|
+
|
|
9
|
+
## 协议
|
|
10
|
+
|
|
11
|
+
`v1alpha1` 定义五个彼此独立的表现协议:
|
|
12
|
+
|
|
13
|
+
- `OpenExternal` 请求客户端打开 HTTP 或 HTTPS URI;
|
|
14
|
+
- `CopyText` 请求客户端把文本复制到剪贴板;
|
|
15
|
+
- `Notification` 请求客户端显示信息、警告或错误文本;
|
|
16
|
+
- `UserInteraction` 承载结构化 question、单次 approval 和 secret input。
|
|
17
|
+
- `ExternalRedirect` 在用户侧接收一次 HTTP redirect,并可按调用方要求独占精确的 loopback URI。
|
|
18
|
+
|
|
19
|
+
Facet 在清单中声明每项所需操作。客户端只为当前连接声明自己能够执行的协议。仅当全部必需表现协议可用时,运行时才接纳命令;运行时也只接受该 facet 事先声明的操作。操作属于当前调用,不是全局事件总线或持久客户端能力。
|
|
20
|
+
|
|
21
|
+
本包提供 protocol definitions、调用作用域内的类型化 client/implementation binder、请求与结果校验。Host 创建 client 时绑定 request identity 与 origin,Consumer 只提交 operation 自有输入。它不执行 UI 工作;原生应用、终端、浏览器、编辑器和自动化客户端可以实现不同子集。
|
|
22
|
+
|
|
23
|
+
普通操作可以从 `@dsh-std/presentation/operations` 导入,交互协议可以从 `@dsh-std/presentation/interaction` 导入。Host 交给领域调用的 `PresentationDescriptor` 只是当前 invocation active agreements 的投影,不是额外的 Snapshot 协议。
|
|
24
|
+
|
|
25
|
+
## 已知限制与暂缓事项
|
|
26
|
+
|
|
27
|
+
- `OpenExternal` 有意拒绝非 HTTP(S) URI scheme。
|
|
28
|
+
- 协议不定义剪贴板读取、任意 UI tree 或文件选择器。
|
|
29
|
+
- `v1alpha1` 不包含投递确认与持久回放。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback.js","names":[],"sources":["../src/callback.ts"],"sourcesContent":["import type {\r\n CapabilityClient,\r\n CapabilityHandlerContext,\r\n CapabilityImplementation,\r\n} from '@dsh-std/connection'\r\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\r\nimport type { ProtocolSupport } from '@dsh-std/core'\r\nimport type { PresentationInvocationScope, PresentationRequestContext, PresentationResult } from './index.js'\r\n\r\nexport const EXTERNAL_REDIRECT_KIND = 'ExternalRedirect'\r\n\r\nexport interface ExternalRedirectRequest extends PresentationRequestContext {\r\n readonly mode: 'http-get'\r\n /** Exact loopback URI required by the external provider, including an explicit port. */\r\n readonly exactRedirectUri?: string\r\n}\r\nexport interface ExternalRedirectInput {\r\n readonly mode?: 'http-get'\r\n /** The provider must bind and announce this exact URI or report the request unavailable. */\r\n readonly exactRedirectUri?: string\r\n}\r\n\r\nexport interface ExternalRedirectReady {\r\n readonly type: 'ready'\r\n readonly redirectUri: string\r\n readonly expiresAt?: string\r\n}\r\n\r\nexport interface ExternalRedirectValue {\r\n readonly query: Readonly<Record<string, readonly string[]>>\r\n}\r\n\r\nexport interface ExternalRedirectCall {\r\n readonly invocationId: string\r\n readonly ready: Promise<ExternalRedirectReady>\r\n readonly result: Promise<PresentationResult<ExternalRedirectValue>>\r\n cancel(reason?: string): void\r\n}\r\n\r\nexport interface ExternalRedirectClient {\r\n receive(input?: ExternalRedirectInput, options?: { readonly signal?: AbortSignal }): ExternalRedirectCall\r\n}\r\n\r\nexport interface ExternalRedirectHandler {\r\n receive(\r\n request: ExternalRedirectRequest,\r\n context: CapabilityHandlerContext<ExternalRedirectReady>,\r\n ): PresentationResult<ExternalRedirectValue> | Promise<PresentationResult<ExternalRedirectValue>>\r\n}\r\n\r\nconst emptySpec = (value: unknown): undefined => {\r\n if (value !== undefined) throw new TypeError('ExternalRedirect does not accept spec in v1alpha1')\r\n return undefined\r\n}\r\n\r\nexport const externalRedirectProtocol = defineCapabilityProtocol({\r\n apiVersion: 'presentation.dsh/v1alpha1', kind: EXTERNAL_REDIRECT_KIND,\r\n validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\nexport const externalRedirectSupport: ProtocolSupport = Object.freeze({\r\n apiVersion: 'presentation.dsh/v1alpha1', kind: EXTERNAL_REDIRECT_KIND,\r\n})\r\n\r\nexport function externalRedirectClient(client: CapabilityClient, scope: PresentationInvocationScope): ExternalRedirectClient {\r\n validateScope(scope)\r\n return Object.freeze({\r\n receive(input: ExternalRedirectInput = {}, options?: { readonly signal?: AbortSignal }) {\r\n const request = Object.freeze({\r\n ...input,\r\n mode: input.mode ?? 'http-get',\r\n requestId: nextRequestId(scope), invocationId: scope.invocationId, origin: scope.origin,\r\n ...(scope.deadline === undefined ? {} : { deadline: scope.deadline }),\r\n })\r\n validateExternalRedirectRequest(request)\r\n const call = client.invoke<ExternalRedirectRequest, PresentationResult<ExternalRedirectValue>, ExternalRedirectReady>(\r\n externalRedirectSupport, 'receive', request, options,\r\n )\r\n return Object.freeze({\r\n invocationId: call.invocationId,\r\n ready: firstReady(call.progress),\r\n result: call.result.then(validateExternalRedirectResult),\r\n cancel: (reason?: string) => call.cancel(reason),\r\n })\r\n },\r\n })\r\n}\r\n\r\nexport function externalRedirectImplementation(\r\n participantId: string,\r\n handler: ExternalRedirectHandler,\r\n): CapabilityImplementation<ExternalRedirectRequest, PresentationResult<ExternalRedirectValue>, ExternalRedirectReady> {\r\n return Object.freeze({\r\n participantId, protocol: externalRedirectSupport,\r\n async handle(operation: string, input: ExternalRedirectRequest, context: CapabilityHandlerContext<ExternalRedirectReady>) {\r\n if (operation !== 'receive') throw new TypeError(`unsupported ExternalRedirect operation ${JSON.stringify(operation)}`)\r\n validateExternalRedirectRequest(input)\r\n let announced = false\r\n const guardedContext: CapabilityHandlerContext<ExternalRedirectReady> = Object.freeze({\r\n ...context,\r\n progress(value: ExternalRedirectReady) {\r\n if (announced) throw new TypeError('ExternalRedirect provider emitted more than one ready event')\r\n validateExternalRedirectReady(value)\r\n if (input.exactRedirectUri !== undefined && value.redirectUri !== input.exactRedirectUri) {\r\n throw new TypeError('ExternalRedirect provider did not announce the exact requested redirect URI')\r\n }\r\n announced = true\r\n context.progress(value)\r\n },\r\n })\r\n const result = validateExternalRedirectResult(await handler.receive(input, guardedContext))\r\n if (result.status === 'submitted' && !announced) {\r\n throw new TypeError('ExternalRedirect provider submitted a result before announcing redirectUri')\r\n }\r\n return result\r\n },\r\n })\r\n}\r\n\r\nexport function validateExternalRedirectRequest(value: unknown): asserts value is ExternalRedirectRequest {\r\n const request = exactRecord(value, ['requestId', 'invocationId', 'origin', 'deadline', 'mode', 'exactRedirectUri'], ['requestId', 'invocationId', 'origin', 'mode'], 'ExternalRedirect request')\r\n nonEmpty(request.requestId, 'ExternalRedirect request.requestId')\r\n nonEmpty(request.invocationId, 'ExternalRedirect request.invocationId')\r\n nonEmpty(request.origin, 'ExternalRedirect request.origin')\r\n if (request.mode !== 'http-get') throw new TypeError('ExternalRedirect request.mode must be \"http-get\"')\r\n if (request.exactRedirectUri !== undefined) validateLoopbackUri(request.exactRedirectUri, 'ExternalRedirect request.exactRedirectUri', true)\r\n dateTime(request.deadline, 'ExternalRedirect request.deadline')\r\n}\r\n\r\nexport function validateExternalRedirectReady(value: unknown): asserts value is ExternalRedirectReady {\r\n const ready = exactRecord(value, ['type', 'redirectUri', 'expiresAt'], ['type', 'redirectUri'], 'ExternalRedirect ready')\r\n if (ready.type !== 'ready') throw new TypeError('ExternalRedirect ready.type must be \"ready\"')\r\n validateLoopbackUri(ready.redirectUri, 'ExternalRedirect ready.redirectUri', false)\r\n dateTime(ready.expiresAt, 'ExternalRedirect ready.expiresAt')\r\n}\r\n\r\nexport function validateExternalRedirectResult(value: unknown): PresentationResult<ExternalRedirectValue> {\r\n if (!record(value)) throw new TypeError('ExternalRedirect result must be an object')\r\n if (value.status === 'submitted') {\r\n const result = exactRecord(value, ['status', 'value'], ['status', 'value'], 'ExternalRedirect result')\r\n const submitted = exactRecord(result.value, ['query'], ['query'], 'ExternalRedirect value')\r\n if (!record(submitted.query)) throw new TypeError('ExternalRedirect value.query must be an object')\r\n const query: Record<string, readonly string[]> = {}\r\n for (const [name, entries] of Object.entries(submitted.query)) {\r\n if (name === '' || !Array.isArray(entries) || entries.some(entry => typeof entry !== 'string')) {\r\n throw new TypeError('ExternalRedirect value.query must map non-empty names to string arrays')\r\n }\r\n query[name] = Object.freeze([...entries])\r\n }\r\n return Object.freeze({ status: 'submitted', value: Object.freeze({ query: Object.freeze(query) }) })\r\n }\r\n if (value.status === 'unavailable') {\r\n const result = exactRecord(value, ['status', 'reason'], ['status'], 'ExternalRedirect result')\r\n if (result.reason !== undefined) nonEmpty(result.reason, 'ExternalRedirect result.reason')\r\n return Object.freeze({ status: 'unavailable', ...(result.reason === undefined ? {} : { reason: result.reason as string }) })\r\n }\r\n if (value.status === 'cancelled' || value.status === 'expired') {\r\n exactRecord(value, ['status'], ['status'], 'ExternalRedirect result')\r\n return Object.freeze({ status: value.status })\r\n }\r\n throw new TypeError('ExternalRedirect result.status is invalid')\r\n}\r\n\r\nasync function firstReady(progress: AsyncIterable<ExternalRedirectReady>): Promise<ExternalRedirectReady> {\r\n for await (const value of progress) {\r\n validateExternalRedirectReady(value)\r\n return Object.freeze({ ...value })\r\n }\r\n throw new TypeError('ExternalRedirect provider completed without announcing redirectUri')\r\n}\r\n\r\nfunction validateScope(scope: PresentationInvocationScope): void {\r\n if (!record(scope)) throw new TypeError('Presentation invocation scope must be an object')\r\n nonEmpty(scope.invocationId, 'Presentation invocation scope.invocationId')\r\n nonEmpty(scope.origin, 'Presentation invocation scope.origin')\r\n dateTime(scope.deadline, 'Presentation invocation scope.deadline')\r\n if (typeof scope.nextRequestId !== 'function') throw new TypeError('Presentation invocation scope.nextRequestId must be a function')\r\n}\r\n\r\nfunction nextRequestId(scope: PresentationInvocationScope): string {\r\n const value = scope.nextRequestId()\r\n nonEmpty(value, 'Presentation requestId')\r\n return value\r\n}\r\n\r\nfunction exactRecord(value: unknown, allowed: readonly string[], required: readonly string[], label: string): Record<string, unknown> {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n const unknown = Object.keys(value).filter(key => !allowed.includes(key))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`)\r\n return value\r\n}\r\nfunction record(value: unknown): value is Record<string, unknown> { return typeof value === 'object' && value !== null && !Array.isArray(value) }\r\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\nfunction dateTime(value: unknown, label: string): void {\r\n if (value !== undefined && (typeof value !== 'string' || Number.isNaN(Date.parse(value)))) throw new TypeError(`${label} must be an RFC 3339 date-time`)\r\n}\r\n\r\nfunction validateLoopbackUri(value: unknown, label: string, requireExplicitPort: boolean): asserts value is string {\r\n nonEmpty(value, label)\r\n let uri: URL\r\n try {\r\n uri = new URL(value)\r\n } catch {\r\n throw new TypeError(`${label} must be an absolute URI`)\r\n }\r\n if (uri.protocol !== 'http:') throw new TypeError(`${label} must use HTTP`)\r\n if (uri.hostname !== '127.0.0.1' && uri.hostname !== '[::1]' && uri.hostname !== 'localhost') {\r\n throw new TypeError(`${label} must target a loopback host`)\r\n }\r\n if (uri.username !== '' || uri.password !== '') throw new TypeError(`${label} must not contain user information`)\r\n if (uri.hash !== '') throw new TypeError(`${label} must not contain a fragment`)\r\n if (requireExplicitPort) {\r\n const authority = value.slice(value.indexOf('//') + 2).split(/[/?#]/u, 1)[0]!\r\n const match = /^(?:127\\.0\\.0\\.1|localhost):(\\d+)$|^\\[::1\\]:(\\d+)$/iu.exec(authority)\r\n const port = Number(match?.[1] ?? match?.[2])\r\n if (!Number.isSafeInteger(port) || port < 1 || port > 65_535) {\r\n throw new TypeError(`${label} must include an explicit TCP port`)\r\n }\r\n }\r\n}\r\n"],"mappings":";;AASA,MAAa,yBAAyB;AAyCtC,MAAM,aAAa,UAA8B;CAC/C,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,UAAU,mDAAmD;AAElG;AAEA,MAAa,2BAA2B,yBAAyB;CAC/D,YAAY;CAA6B,MAAM;CAC/C,qBAAqB;CAAW,iBAAiB;AACnD,CAAC;AACD,MAAa,0BAA2C,OAAO,OAAO;CACpE,YAAY;CAA6B,MAAM;AACjD,CAAC;AAED,SAAgB,uBAAuB,QAA0B,OAA4D;CAC3H,cAAc,KAAK;CACnB,OAAO,OAAO,OAAO,EACnB,QAAQ,QAA+B,CAAC,GAAG,SAA6C;EACtF,MAAM,UAAU,OAAO,OAAO;GAC5B,GAAG;GACH,MAAM,MAAM,QAAQ;GACpB,WAAW,cAAc,KAAK;GAAG,cAAc,MAAM;GAAc,QAAQ,MAAM;GACjF,GAAI,MAAM,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,MAAM,SAAS;EACrE,CAAC;EACD,gCAAgC,OAAO;EACvC,MAAM,OAAO,OAAO,OAClB,yBAAyB,WAAW,SAAS,OAC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AAE;EAC5C,IAAI,CAAC,OAAO,cAAc,IAAI,KAAK,OAAO,KAAK,OAAO,OACpD,MAAM,IAAI,UAAU,GAAG,MAAM,mCAAmC;CAEpE;AACF"}
|
|
1
|
+
{"version":3,"file":"callback.js","names":[],"sources":["../src/callback.ts"],"sourcesContent":["import type {\n CapabilityClient,\n CapabilityHandlerContext,\n CapabilityImplementation,\n} from '@dsh-std/connection'\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\nimport type { ProtocolSupport } from '@dsh-std/core'\nimport type { PresentationInvocationScope, PresentationRequestContext, PresentationResult } from './index.js'\n\nexport const EXTERNAL_REDIRECT_KIND = 'ExternalRedirect'\n\nexport interface ExternalRedirectRequest extends PresentationRequestContext {\n readonly mode: 'http-get'\n /** Exact loopback URI required by the external provider, including an explicit port. */\n readonly exactRedirectUri?: string\n}\nexport interface ExternalRedirectInput {\n readonly mode?: 'http-get'\n /** The provider must bind and announce this exact URI or report the request unavailable. */\n readonly exactRedirectUri?: string\n}\n\nexport interface ExternalRedirectReady {\n readonly type: 'ready'\n readonly redirectUri: string\n readonly expiresAt?: string\n}\n\nexport interface ExternalRedirectValue {\n readonly query: Readonly<Record<string, readonly string[]>>\n}\n\nexport interface ExternalRedirectCall {\n readonly invocationId: string\n readonly ready: Promise<ExternalRedirectReady>\n readonly result: Promise<PresentationResult<ExternalRedirectValue>>\n cancel(reason?: string): void\n}\n\nexport interface ExternalRedirectClient {\n receive(input?: ExternalRedirectInput, options?: { readonly signal?: AbortSignal }): ExternalRedirectCall\n}\n\nexport interface ExternalRedirectHandler {\n receive(\n request: ExternalRedirectRequest,\n context: CapabilityHandlerContext<ExternalRedirectReady>,\n ): PresentationResult<ExternalRedirectValue> | Promise<PresentationResult<ExternalRedirectValue>>\n}\n\nconst emptySpec = (value: unknown): undefined => {\n if (value !== undefined) throw new TypeError('ExternalRedirect does not accept spec in v1alpha1')\n return undefined\n}\n\nexport const externalRedirectProtocol = defineCapabilityProtocol({\n apiVersion: 'presentation.dsh/v1alpha1', kind: EXTERNAL_REDIRECT_KIND,\n validateRequirement: emptySpec, validateSupport: emptySpec,\n})\nexport const externalRedirectSupport: ProtocolSupport = Object.freeze({\n apiVersion: 'presentation.dsh/v1alpha1', kind: EXTERNAL_REDIRECT_KIND,\n})\n\nexport function externalRedirectClient(client: CapabilityClient, scope: PresentationInvocationScope): ExternalRedirectClient {\n validateScope(scope)\n return Object.freeze({\n receive(input: ExternalRedirectInput = {}, options?: { readonly signal?: AbortSignal }) {\n const request = Object.freeze({\n ...input,\n mode: input.mode ?? 'http-get',\n requestId: nextRequestId(scope), invocationId: scope.invocationId, origin: scope.origin,\n ...(scope.deadline === undefined ? {} : { deadline: scope.deadline }),\n })\n validateExternalRedirectRequest(request)\n const call = client.invoke<ExternalRedirectRequest, PresentationResult<ExternalRedirectValue>, ExternalRedirectReady>(\n externalRedirectSupport, 'receive', request, options,\n )\n return Object.freeze({\n invocationId: call.invocationId,\n ready: firstReady(call.progress),\n result: call.result.then(validateExternalRedirectResult),\n cancel: (reason?: string) => call.cancel(reason),\n })\n },\n })\n}\n\nexport function externalRedirectImplementation(\n participantId: string,\n handler: ExternalRedirectHandler,\n): CapabilityImplementation<ExternalRedirectRequest, PresentationResult<ExternalRedirectValue>, ExternalRedirectReady> {\n return Object.freeze({\n participantId, protocol: externalRedirectSupport,\n async handle(operation: string, input: ExternalRedirectRequest, context: CapabilityHandlerContext<ExternalRedirectReady>) {\n if (operation !== 'receive') throw new TypeError(`unsupported ExternalRedirect operation ${JSON.stringify(operation)}`)\n validateExternalRedirectRequest(input)\n let announced = false\n const guardedContext: CapabilityHandlerContext<ExternalRedirectReady> = Object.freeze({\n ...context,\n progress(value: ExternalRedirectReady) {\n if (announced) throw new TypeError('ExternalRedirect provider emitted more than one ready event')\n validateExternalRedirectReady(value)\n if (input.exactRedirectUri !== undefined && value.redirectUri !== input.exactRedirectUri) {\n throw new TypeError('ExternalRedirect provider did not announce the exact requested redirect URI')\n }\n announced = true\n context.progress(value)\n },\n })\n const result = validateExternalRedirectResult(await handler.receive(input, guardedContext))\n if (result.status === 'submitted' && !announced) {\n throw new TypeError('ExternalRedirect provider submitted a result before announcing redirectUri')\n }\n return result\n },\n })\n}\n\nexport function validateExternalRedirectRequest(value: unknown): asserts value is ExternalRedirectRequest {\n const request = exactRecord(value, ['requestId', 'invocationId', 'origin', 'deadline', 'mode', 'exactRedirectUri'], ['requestId', 'invocationId', 'origin', 'mode'], 'ExternalRedirect request')\n nonEmpty(request.requestId, 'ExternalRedirect request.requestId')\n nonEmpty(request.invocationId, 'ExternalRedirect request.invocationId')\n nonEmpty(request.origin, 'ExternalRedirect request.origin')\n if (request.mode !== 'http-get') throw new TypeError('ExternalRedirect request.mode must be \"http-get\"')\n if (request.exactRedirectUri !== undefined) validateLoopbackUri(request.exactRedirectUri, 'ExternalRedirect request.exactRedirectUri', true)\n dateTime(request.deadline, 'ExternalRedirect request.deadline')\n}\n\nexport function validateExternalRedirectReady(value: unknown): asserts value is ExternalRedirectReady {\n const ready = exactRecord(value, ['type', 'redirectUri', 'expiresAt'], ['type', 'redirectUri'], 'ExternalRedirect ready')\n if (ready.type !== 'ready') throw new TypeError('ExternalRedirect ready.type must be \"ready\"')\n validateLoopbackUri(ready.redirectUri, 'ExternalRedirect ready.redirectUri', false)\n dateTime(ready.expiresAt, 'ExternalRedirect ready.expiresAt')\n}\n\nexport function validateExternalRedirectResult(value: unknown): PresentationResult<ExternalRedirectValue> {\n if (!record(value)) throw new TypeError('ExternalRedirect result must be an object')\n if (value.status === 'submitted') {\n const result = exactRecord(value, ['status', 'value'], ['status', 'value'], 'ExternalRedirect result')\n const submitted = exactRecord(result.value, ['query'], ['query'], 'ExternalRedirect value')\n if (!record(submitted.query)) throw new TypeError('ExternalRedirect value.query must be an object')\n const query: Record<string, readonly string[]> = {}\n for (const [name, entries] of Object.entries(submitted.query)) {\n if (name === '' || !Array.isArray(entries) || entries.some(entry => typeof entry !== 'string')) {\n throw new TypeError('ExternalRedirect value.query must map non-empty names to string arrays')\n }\n query[name] = Object.freeze([...entries])\n }\n return Object.freeze({ status: 'submitted', value: Object.freeze({ query: Object.freeze(query) }) })\n }\n if (value.status === 'unavailable') {\n const result = exactRecord(value, ['status', 'reason'], ['status'], 'ExternalRedirect result')\n if (result.reason !== undefined) nonEmpty(result.reason, 'ExternalRedirect result.reason')\n return Object.freeze({ status: 'unavailable', ...(result.reason === undefined ? {} : { reason: result.reason as string }) })\n }\n if (value.status === 'cancelled' || value.status === 'expired') {\n exactRecord(value, ['status'], ['status'], 'ExternalRedirect result')\n return Object.freeze({ status: value.status })\n }\n throw new TypeError('ExternalRedirect result.status is invalid')\n}\n\nasync function firstReady(progress: AsyncIterable<ExternalRedirectReady>): Promise<ExternalRedirectReady> {\n for await (const value of progress) {\n validateExternalRedirectReady(value)\n return Object.freeze({ ...value })\n }\n throw new TypeError('ExternalRedirect provider completed without announcing redirectUri')\n}\n\nfunction validateScope(scope: PresentationInvocationScope): void {\n if (!record(scope)) throw new TypeError('Presentation invocation scope must be an object')\n nonEmpty(scope.invocationId, 'Presentation invocation scope.invocationId')\n nonEmpty(scope.origin, 'Presentation invocation scope.origin')\n dateTime(scope.deadline, 'Presentation invocation scope.deadline')\n if (typeof scope.nextRequestId !== 'function') throw new TypeError('Presentation invocation scope.nextRequestId must be a function')\n}\n\nfunction nextRequestId(scope: PresentationInvocationScope): string {\n const value = scope.nextRequestId()\n nonEmpty(value, 'Presentation requestId')\n return value\n}\n\nfunction exactRecord(value: unknown, allowed: readonly string[], required: readonly string[], label: string): Record<string, unknown> {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n const unknown = Object.keys(value).filter(key => !allowed.includes(key))\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\n for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`)\n return value\n}\nfunction record(value: unknown): value is Record<string, unknown> { return typeof value === 'object' && value !== null && !Array.isArray(value) }\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\nfunction dateTime(value: unknown, label: string): void {\n if (value !== undefined && (typeof value !== 'string' || Number.isNaN(Date.parse(value)))) throw new TypeError(`${label} must be an RFC 3339 date-time`)\n}\n\nfunction validateLoopbackUri(value: unknown, label: string, requireExplicitPort: boolean): asserts value is string {\n nonEmpty(value, label)\n let uri: URL\n try {\n uri = new URL(value)\n } catch {\n throw new TypeError(`${label} must be an absolute URI`)\n }\n if (uri.protocol !== 'http:') throw new TypeError(`${label} must use HTTP`)\n if (uri.hostname !== '127.0.0.1' && uri.hostname !== '[::1]' && uri.hostname !== 'localhost') {\n throw new TypeError(`${label} must target a loopback host`)\n }\n if (uri.username !== '' || uri.password !== '') throw new TypeError(`${label} must not contain user information`)\n if (uri.hash !== '') throw new TypeError(`${label} must not contain a fragment`)\n if (requireExplicitPort) {\n const authority = value.slice(value.indexOf('//') + 2).split(/[/?#]/u, 1)[0]!\n const match = /^(?:127\\.0\\.0\\.1|localhost):(\\d+)$|^\\[::1\\]:(\\d+)$/iu.exec(authority)\n const port = Number(match?.[1] ?? match?.[2])\n if (!Number.isSafeInteger(port) || port < 1 || port > 65_535) {\n throw new TypeError(`${label} must include an explicit TCP port`)\n }\n }\n}\n"],"mappings":";;AASA,MAAa,yBAAyB;AAyCtC,MAAM,aAAa,UAA8B;CAC/C,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,UAAU,mDAAmD;AAElG;AAEA,MAAa,2BAA2B,yBAAyB;CAC/D,YAAY;CAA6B,MAAM;CAC/C,qBAAqB;CAAW,iBAAiB;AACnD,CAAC;AACD,MAAa,0BAA2C,OAAO,OAAO;CACpE,YAAY;CAA6B,MAAM;AACjD,CAAC;AAED,SAAgB,uBAAuB,QAA0B,OAA4D;CAC3H,cAAc,KAAK;CACnB,OAAO,OAAO,OAAO,EACnB,QAAQ,QAA+B,CAAC,GAAG,SAA6C;EACtF,M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AChH,IAAI,IAAI,SAAS,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,6BAA6B;CAC/E,IAAI,qBAAqB;EACvB,MAAM,YAAY,MAAM,MAAM,MAAM,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC;EAC1E,MAAM,QAAQ,uDAAuD,KAAK,SAAS;EACnF,MAAM,OAAO,OAAO,QAAQ,MAAM,QAAQ,EAAE;EAC5C,IAAI,CAAC,OAAO,cAAc,IAAI,KAAK,OAAO,KAAK,OAAO,OACpD,MAAM,IAAI,UAAU,GAAG,MAAM,mCAAmC;CAEpE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\r\n ProtocolCatalog,\r\n ProtocolDefinition,\r\n ProtocolIssue,\r\n ProtocolNegotiationInput,\r\n ProtocolRequirement,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\nimport type {\r\n CapabilityClient,\r\n CapabilityHandlerContext,\r\n CapabilityImplementation,\r\n ConnectionNegotiationPolicy,\r\n} from '@dsh-std/connection'\r\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\r\nimport { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectProtocol } from './callback.js'\r\nimport type { ExternalRedirectClient } from './callback.js'\r\n\r\nexport * from './callback.js'\r\n\r\nexport const API_VERSION = 'presentation.dsh/v1alpha1'\r\nexport const OPEN_EXTERNAL_KIND = 'OpenExternal'\r\nexport const COPY_TEXT_KIND = 'CopyText'\r\nexport const NOTIFICATION_KIND = 'Notification'\r\nexport const USER_INTERACTION_KIND = 'UserInteraction'\r\n\r\nexport interface PresentationDescriptor {\r\n /** Endpoint identity selected and authenticated by the Host for this invocation. */\r\n readonly clientId: string\r\n /** Active Presentation agreements projected into this invocation. */\r\n readonly contracts: readonly ProtocolSupport[]\r\n}\r\n\r\nexport interface PresentationRequestContext {\r\n readonly requestId: string\r\n readonly invocationId: string\r\n readonly origin: string\r\n readonly deadline?: string\r\n}\r\n\r\n/** Invocation authority supplied by the Host when it creates scoped clients. */\r\nexport interface PresentationInvocationScope {\r\n readonly invocationId: string\r\n readonly origin: string\r\n readonly deadline?: string\r\n nextRequestId(): string\r\n}\r\n\r\nexport type PresentationResult<T> =\r\n | { readonly status: 'submitted'; readonly value: T }\r\n | { readonly status: 'cancelled' }\r\n | { readonly status: 'expired' }\r\n | { readonly status: 'unavailable'; readonly reason?: string }\r\n\r\nexport interface OpenExternalRequest extends PresentationRequestContext {\r\n readonly uri: string\r\n}\r\n\r\nexport type OpenExternalInput = Omit<OpenExternalRequest, keyof PresentationRequestContext>\r\n\r\nexport interface OpenExternalReceipt { readonly accepted: true }\r\n\r\nexport interface CopyTextRequest extends PresentationRequestContext {\r\n readonly text: string\r\n readonly sensitivity?: 'public' | 'private'\r\n}\r\n\r\nexport type CopyTextInput = Omit<CopyTextRequest, keyof PresentationRequestContext>\r\n\r\nexport interface CopyTextReceipt { readonly accepted: true }\r\n\r\nexport interface NotificationRequest extends PresentationRequestContext {\r\n readonly text: string\r\n readonly level?: 'info' | 'warning' | 'error'\r\n readonly deduplicationKey?: string\r\n}\r\n\r\nexport type NotificationInput = Omit<NotificationRequest, keyof PresentationRequestContext>\r\n\r\nexport interface NotificationReceipt { readonly accepted: true }\r\n\r\nexport type UserInteractionOperation = 'question' | 'approval' | 'secret-input'\r\n\r\nexport interface UserInteractionRequirementSpec {\r\n readonly operations: readonly UserInteractionOperation[]\r\n readonly optionalOperations?: readonly UserInteractionOperation[]\r\n}\r\n\r\nexport interface UserInteractionLimits {\r\n readonly maxConcurrentRequests?: number\r\n readonly maxFields?: number\r\n readonly maxOptionsPerField?: number\r\n readonly maxTextLength?: number\r\n}\r\n\r\nexport interface UserInteractionSupportSpec {\r\n readonly operations: readonly UserInteractionOperation[]\r\n readonly limits?: UserInteractionLimits\r\n}\r\n\r\nexport interface QuestionOption {\r\n readonly id: string\r\n readonly label: string\r\n readonly description?: string\r\n}\r\n\r\ninterface QuestionFieldBase {\r\n readonly id: string\r\n readonly label: string\r\n readonly description?: string\r\n readonly required?: boolean\r\n}\r\n\r\nexport interface TextQuestionField extends QuestionFieldBase {\r\n readonly kind: 'text'\r\n readonly multiline?: boolean\r\n readonly minLength?: number\r\n readonly maxLength?: number\r\n}\r\n\r\nexport interface SelectQuestionField extends QuestionFieldBase {\r\n readonly kind: 'select'\r\n readonly multiple?: boolean\r\n readonly options: readonly QuestionOption[]\r\n}\r\n\r\nexport interface ConfirmQuestionField extends QuestionFieldBase {\r\n readonly kind: 'confirm'\r\n}\r\n\r\nexport type QuestionField = TextQuestionField | SelectQuestionField | ConfirmQuestionField\r\n\r\nexport interface QuestionRequest extends PresentationRequestContext {\r\n readonly kind: 'question'\r\n readonly title?: string\r\n readonly description?: string\r\n readonly fields: readonly QuestionField[]\r\n}\r\n\r\nexport interface QuestionAnswers {\r\n readonly answers: Readonly<Record<string, string | boolean | readonly string[]>>\r\n}\r\n\r\nexport interface ApprovalDetail {\r\n readonly label: string\r\n readonly value: string\r\n readonly sensitivity?: 'public' | 'private'\r\n}\r\n\r\nexport interface ApprovalRequest extends PresentationRequestContext {\r\n readonly kind: 'approval'\r\n readonly action: string\r\n readonly summary: string\r\n readonly details?: readonly ApprovalDetail[]\r\n readonly risk?: 'low' | 'medium' | 'high'\r\n}\r\n\r\nexport interface ApprovalValue { readonly decision: 'approved' | 'denied' }\r\n\r\nexport interface SecretInputRequest extends PresentationRequestContext {\r\n readonly kind: 'secret-input'\r\n readonly label: string\r\n readonly description?: string\r\n readonly minLength?: number\r\n readonly maxLength?: number\r\n}\r\n\r\nexport interface SecretInputValue { readonly secret: string }\r\n\r\nexport type UserInteractionRequest = QuestionRequest | ApprovalRequest | SecretInputRequest\r\nexport type UserInteractionValue = QuestionAnswers | ApprovalValue | SecretInputValue\r\nexport type QuestionInput = Omit<QuestionRequest, keyof PresentationRequestContext>\r\nexport type ApprovalInput = Omit<ApprovalRequest, keyof PresentationRequestContext>\r\nexport type SecretInput = Omit<SecretInputRequest, keyof PresentationRequestContext>\r\n\r\nexport interface OpenExternalClient {\r\n openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<OpenExternalReceipt>>\r\n}\r\n\r\nexport interface CopyTextClient {\r\n copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<CopyTextReceipt>>\r\n}\r\n\r\nexport interface NotificationClient {\r\n notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<NotificationReceipt>>\r\n}\r\n\r\nexport interface UserInteractionClient {\r\n interact(input: QuestionInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<QuestionAnswers>>\r\n interact(input: ApprovalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<ApprovalValue>>\r\n interact(input: SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<SecretInputValue>>\r\n}\r\n\r\n/** Typed Presentation capabilities available to one domain invocation. */\r\nexport interface PresentationClients {\r\n readonly descriptor: PresentationDescriptor\r\n readonly openExternal?: OpenExternalClient\r\n readonly copyText?: CopyTextClient\r\n readonly notification?: NotificationClient\r\n readonly interaction?: UserInteractionClient\r\n readonly externalRedirect?: ExternalRedirectClient\r\n}\r\n\r\nexport interface OpenExternalHandler {\r\n openExternal(request: OpenExternalRequest, context: CapabilityHandlerContext): PresentationResult<OpenExternalReceipt> | Promise<PresentationResult<OpenExternalReceipt>>\r\n}\r\n\r\nexport interface CopyTextHandler {\r\n copyText(request: CopyTextRequest, context: CapabilityHandlerContext): PresentationResult<CopyTextReceipt> | Promise<PresentationResult<CopyTextReceipt>>\r\n}\r\n\r\nexport interface NotificationHandler {\r\n notify(request: NotificationRequest, context: CapabilityHandlerContext): PresentationResult<NotificationReceipt> | Promise<PresentationResult<NotificationReceipt>>\r\n}\r\n\r\nexport interface UserInteractionHandler {\r\n interact(request: QuestionRequest, context: CapabilityHandlerContext): PresentationResult<QuestionAnswers> | Promise<PresentationResult<QuestionAnswers>>\r\n interact(request: ApprovalRequest, context: CapabilityHandlerContext): PresentationResult<ApprovalValue> | Promise<PresentationResult<ApprovalValue>>\r\n interact(request: SecretInputRequest, context: CapabilityHandlerContext): PresentationResult<SecretInputValue> | Promise<PresentationResult<SecretInputValue>>\r\n}\r\n\r\nconst emptySpec = (value: unknown): undefined => {\r\n if (value !== undefined) throw new TypeError('Presentation operation does not accept spec in v1alpha1')\r\n return undefined\r\n}\r\n\r\nexport const openExternalProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\nexport const copyTextProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: COPY_TEXT_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\nexport const notificationProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: NOTIFICATION_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\n\r\nexport const openExternalSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND })\r\nexport const copyTextSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: COPY_TEXT_KIND })\r\nexport const notificationSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: NOTIFICATION_KIND })\r\nexport const userInteractionSupport = (spec: UserInteractionSupportSpec): ProtocolSupport<UserInteractionSupportSpec> =>\r\n Object.freeze({ apiVersion: API_VERSION, kind: USER_INTERACTION_KIND, spec: validateUserInteractionSupport(spec) })\r\n\r\nexport const userInteractionProtocol: ProtocolDefinition<\r\n UserInteractionRequirementSpec,\r\n UserInteractionSupportSpec\r\n> = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: USER_INTERACTION_KIND,\r\n validateRequirement: validateUserInteractionRequirement,\r\n validateSupport: validateUserInteractionSupport,\r\n negotiate: negotiateUserInteraction,\r\n})\r\n\r\nexport const protocols: readonly ProtocolDefinition[] = Object.freeze([\r\n openExternalProtocol,\r\n copyTextProtocol,\r\n notificationProtocol,\r\n userInteractionProtocol,\r\n externalRedirectProtocol,\r\n])\r\n\r\nexport function register(catalog: ProtocolCatalog): () => void {\r\n const disposers = protocols.map(protocol => catalog.register(protocol))\r\n return () => { for (const dispose of disposers.reverse()) dispose() }\r\n}\r\n\r\nexport function openExternalClient(client: CapabilityClient, scope: PresentationInvocationScope): OpenExternalClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateOpenExternalRequest(value)\r\n const result = await client.invoke<OpenExternalRequest, PresentationResult<OpenExternalReceipt>>(\r\n openExternalSupport, 'openExternal', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result')\r\n },\r\n })\r\n}\r\n\r\nexport function copyTextClient(client: CapabilityClient, scope: PresentationInvocationScope): CopyTextClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateCopyTextRequest(value)\r\n const result = await client.invoke<CopyTextRequest, PresentationResult<CopyTextReceipt>>(\r\n copyTextSupport, 'copyText', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result')\r\n },\r\n })\r\n}\r\n\r\nexport function notificationClient(client: CapabilityClient, scope: PresentationInvocationScope): NotificationClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateNotificationRequest(value)\r\n const result = await client.invoke<NotificationRequest, PresentationResult<NotificationReceipt>>(\r\n notificationSupport, 'notify', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'Notification result')\r\n },\r\n })\r\n}\r\n\r\nexport function userInteractionClient(client: CapabilityClient, scope: PresentationInvocationScope): UserInteractionClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async interact(input: QuestionInput | ApprovalInput | SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<UserInteractionValue>> {\r\n const value = request(input) as UserInteractionRequest\r\n validateUserInteractionRequest(value)\r\n const result = await client.invoke<UserInteractionRequest, PresentationResult<UserInteractionValue>>(\r\n { apiVersion: API_VERSION, kind: USER_INTERACTION_KIND }, 'interact', value, options,\r\n ).result\r\n return validateInteractionResult(value, result)\r\n },\r\n }) as UserInteractionClient\r\n}\r\n\r\nexport function presentationClients(\r\n descriptor: PresentationDescriptor,\r\n client: CapabilityClient,\r\n scope: PresentationInvocationScope,\r\n): PresentationClients {\r\n validatePresentationDescriptor(descriptor)\r\n validateInvocationScope(scope)\r\n const has = (kind: string) => descriptor.contracts.some(contract =>\r\n contract.apiVersion === API_VERSION && contract.kind === kind && client.binding(contract) !== undefined)\r\n return Object.freeze({\r\n descriptor: freezeClone(descriptor),\r\n ...(has(OPEN_EXTERNAL_KIND) ? { openExternal: openExternalClient(client, scope) } : {}),\r\n ...(has(COPY_TEXT_KIND) ? { copyText: copyTextClient(client, scope) } : {}),\r\n ...(has(NOTIFICATION_KIND) ? { notification: notificationClient(client, scope) } : {}),\r\n ...(has(USER_INTERACTION_KIND) ? { interaction: userInteractionClient(client, scope) } : {}),\r\n ...(has(EXTERNAL_REDIRECT_KIND) ? { externalRedirect: externalRedirectClient(client, scope) } : {}),\r\n })\r\n}\r\n\r\nexport function openExternalImplementation(participantId: string, handler: OpenExternalHandler): CapabilityImplementation {\r\n return implementation(participantId, openExternalSupport, 'openExternal', validateOpenExternalRequest, handler.openExternal.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result'))\r\n}\r\n\r\nexport function copyTextImplementation(participantId: string, handler: CopyTextHandler): CapabilityImplementation {\r\n return implementation(participantId, copyTextSupport, 'copyText', validateCopyTextRequest, handler.copyText.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result'))\r\n}\r\n\r\nexport function notificationImplementation(participantId: string, handler: NotificationHandler): CapabilityImplementation {\r\n return implementation(participantId, notificationSupport, 'notify', validateNotificationRequest, handler.notify.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'Notification result'))\r\n}\r\n\r\nexport function userInteractionImplementation(\r\n participantId: string,\r\n spec: UserInteractionSupportSpec,\r\n handler: UserInteractionHandler,\r\n): CapabilityImplementation {\r\n const protocol = userInteractionSupport(spec)\r\n return Object.freeze({\r\n participantId,\r\n protocol,\r\n async handle(operationName: string, input: unknown, context: CapabilityHandlerContext) {\r\n if (operationName !== 'interact') throw new TypeError(`unsupported UserInteraction operation ${JSON.stringify(operationName)}`)\r\n validateUserInteractionRequest(input)\r\n if (!spec.operations.includes(input.kind)) throw new TypeError(`UserInteraction provider does not support ${JSON.stringify(input.kind)}`)\r\n const result = await handler.interact(input as never, context)\r\n return validateInteractionResult(input, result)\r\n },\r\n })\r\n}\r\n\r\nexport function validatePresentationDescriptor(value: unknown): asserts value is PresentationDescriptor {\r\n const descriptor = exactRecord(value, ['clientId', 'contracts'], ['clientId', 'contracts'], 'Presentation descriptor')\r\n nonEmpty(descriptor.clientId, 'Presentation descriptor.clientId')\r\n if (!Array.isArray(descriptor.contracts)) throw new TypeError('Presentation descriptor.contracts must be an array')\r\n const seen = new Set<string>()\r\n for (const [index, contractValue] of descriptor.contracts.entries()) {\r\n const contract = exactRecord(contractValue, ['apiVersion', 'kind', 'spec'], ['apiVersion', 'kind'], `Presentation descriptor.contracts[${index}]`)\r\n nonEmpty(contract.apiVersion, `Presentation descriptor.contracts[${index}].apiVersion`)\r\n nonEmpty(contract.kind, `Presentation descriptor.contracts[${index}].kind`)\r\n const key = `${String(contract.apiVersion)}\\0${String(contract.kind)}`\r\n if (seen.has(key)) throw new TypeError(`Presentation descriptor contains duplicate contract ${JSON.stringify(key)}`)\r\n seen.add(key)\r\n }\r\n}\r\n\r\nexport function validateOpenExternalRequest(value: unknown): asserts value is OpenExternalRequest {\r\n const request = requestRecord(value, ['uri'], 'OpenExternal request')\r\n nonEmpty(request.uri, 'OpenExternal request.uri')\r\n const uri = new URL(request.uri as string)\r\n if (uri.protocol !== 'https:' && uri.protocol !== 'http:') throw new TypeError('OpenExternal only accepts HTTP(S) URIs')\r\n}\r\n\r\nexport function validateCopyTextRequest(value: unknown): asserts value is CopyTextRequest {\r\n const request = requestRecord(value, ['text', 'sensitivity'], 'CopyText request')\r\n nonEmpty(request.text, 'CopyText request.text')\r\n if (request.sensitivity !== undefined && request.sensitivity !== 'public' && request.sensitivity !== 'private') {\r\n throw new TypeError('CopyText request.sensitivity is invalid')\r\n }\r\n}\r\n\r\nexport function validateNotificationRequest(value: unknown): asserts value is NotificationRequest {\r\n const request = requestRecord(value, ['text', 'level', 'deduplicationKey'], 'Notification request')\r\n nonEmpty(request.text, 'Notification request.text')\r\n if (request.level !== undefined && request.level !== 'info' && request.level !== 'warning' && request.level !== 'error') {\r\n throw new TypeError('Notification request.level is invalid')\r\n }\r\n if (request.deduplicationKey !== undefined) nonEmpty(request.deduplicationKey, 'Notification request.deduplicationKey')\r\n}\r\n\r\nexport function validateUserInteractionRequest(value: unknown): asserts value is UserInteractionRequest {\r\n if (!record(value)) throw new TypeError('UserInteraction request must be an object')\r\n if (value.kind === 'question') return validateQuestionRequest(value)\r\n if (value.kind === 'approval') return validateApprovalRequest(value)\r\n if (value.kind === 'secret-input') return validateSecretInputRequest(value)\r\n throw new TypeError('UserInteraction request.kind is invalid')\r\n}\r\n\r\nexport function validateUserInteractionRequirement(value: unknown): UserInteractionRequirementSpec {\r\n const spec = exactRecord(value, ['operations', 'optionalOperations'], ['operations'], 'UserInteraction requirement spec')\r\n const operations = operationList(spec.operations, 'UserInteraction requirement spec.operations')\r\n const optionalOperations = spec.optionalOperations === undefined\r\n ? undefined\r\n : operationList(spec.optionalOperations, 'UserInteraction requirement spec.optionalOperations')\r\n if (optionalOperations?.some(operation => operations.includes(operation)) === true) {\r\n throw new TypeError('UserInteraction optionalOperations must not duplicate required operations')\r\n }\r\n return deepFreeze({ operations, ...(optionalOperations === undefined ? {} : { optionalOperations }) })\r\n}\r\n\r\nexport function validateUserInteractionSupport(value: unknown): UserInteractionSupportSpec {\r\n const spec = exactRecord(value, ['operations', 'limits'], ['operations'], 'UserInteraction support spec')\r\n const operations = operationList(spec.operations, 'UserInteraction support spec.operations')\r\n const limits = spec.limits === undefined ? undefined : validateLimits(spec.limits)\r\n return deepFreeze({ operations, ...(limits === undefined ? {} : { limits }) })\r\n}\r\n\r\nfunction negotiateUserInteraction(\r\n input: ProtocolNegotiationInput<UserInteractionRequirementSpec, UserInteractionSupportSpec>,\r\n) {\r\n const issues: ProtocolIssue[] = []\r\n const bindings: Array<{\r\n readonly consumer: string\r\n readonly provider: string\r\n readonly requirement: ProtocolRequirement<UserInteractionRequirementSpec>\r\n readonly support: ProtocolSupport<UserInteractionSupportSpec>\r\n }> = []\r\n const connectionPolicy = connectionNegotiationPolicy(input.policy)\r\n for (const row of input.requirements) {\r\n const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant]\r\n const candidates = input.supports.filter(candidate => {\r\n if (candidate.participant === row.participant) return false\r\n if (consumerEndpoint !== undefined && connectionPolicy?.endpointByParticipant[candidate.participant] === consumerEndpoint) return false\r\n return row.requirement.spec!.operations.every(operation => candidate.support.spec!.operations.includes(operation))\r\n })\r\n if (candidates.length === 0) {\r\n issues.push(Object.freeze({\r\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\r\n severity: row.requirement.optional === true ? 'warning' : 'error',\r\n participant: row.participant,\r\n message: `no participant supports the required ${USER_INTERACTION_KIND} operations`,\r\n }))\r\n continue\r\n }\r\n if (candidates.length > 1) {\r\n issues.push(Object.freeze({\r\n code: 'support-ambiguous', severity: 'error', participant: row.participant,\r\n message: `multiple participants support ${API_VERSION} ${USER_INTERACTION_KIND}`,\r\n }))\r\n continue\r\n }\r\n const provider = candidates[0]!\r\n bindings.push(Object.freeze({\r\n consumer: row.participant,\r\n provider: provider.participant,\r\n requirement: row.requirement,\r\n support: provider.support,\r\n }))\r\n for (const operation of row.requirement.spec!.optionalOperations ?? []) {\r\n if (provider.support.spec!.operations.includes(operation)) continue\r\n issues.push(Object.freeze({\r\n code: 'optional-operation-missing', severity: 'warning', participant: row.participant,\r\n message: `${USER_INTERACTION_KIND} provider does not support optional operation ${JSON.stringify(operation)}`,\r\n }))\r\n }\r\n }\r\n return {\r\n agreement: Object.freeze({ kind: 'CapabilityBindings' as const, bindings: Object.freeze(bindings) }),\r\n issues: Object.freeze(issues),\r\n }\r\n}\r\n\r\nfunction connectionNegotiationPolicy(value: unknown): ConnectionNegotiationPolicy | undefined {\r\n return record(value) && record(value.endpointByParticipant)\r\n ? value as unknown as ConnectionNegotiationPolicy\r\n : undefined\r\n}\r\n\r\nfunction implementation<TInput, TOutput>(\r\n participantId: string,\r\n protocol: ProtocolSupport,\r\n operationName: string,\r\n validateInput: (value: unknown) => asserts value is TInput,\r\n handler: (input: TInput, context: CapabilityHandlerContext) => TOutput | Promise<TOutput>,\r\n validateOutput: (value: unknown) => TOutput,\r\n): CapabilityImplementation {\r\n return Object.freeze({\r\n participantId,\r\n protocol,\r\n async handle(operation: string, input: unknown, context: CapabilityHandlerContext) {\r\n if (operation !== operationName) throw new TypeError(`unsupported ${protocol.kind} operation ${JSON.stringify(operation)}`)\r\n validateInput(input)\r\n return validateOutput(await handler(input, context))\r\n },\r\n })\r\n}\r\n\r\nfunction validateQuestionRequest(value: unknown): asserts value is QuestionRequest {\r\n const request = requestRecord(value, ['kind', 'title', 'description', 'fields'], 'Question request')\r\n if (request.kind !== 'question') throw new TypeError('Question request.kind must be \"question\"')\r\n optionalText(request.title, 'Question request.title')\r\n optionalText(request.description, 'Question request.description')\r\n if (!Array.isArray(request.fields) || request.fields.length === 0) throw new TypeError('Question request.fields must be a non-empty array')\r\n const ids = new Set<string>()\r\n for (const [index, fieldValue] of request.fields.entries()) {\r\n const label = `Question request.fields[${index}]`\r\n if (!record(fieldValue)) throw new TypeError(`${label} must be an object`)\r\n const common = ['id', 'kind', 'label', 'description', 'required']\r\n const allowed = fieldValue.kind === 'text' ? [...common, 'multiline', 'minLength', 'maxLength']\r\n : fieldValue.kind === 'select' ? [...common, 'multiple', 'options'] : common\r\n const field = exactRecord(fieldValue, allowed, ['id', 'kind', 'label'], label)\r\n localId(field.id, `${label}.id`)\r\n if (ids.has(field.id as string)) throw new TypeError('Question request contains duplicate field id')\r\n ids.add(field.id as string)\r\n nonEmpty(field.label, `${label}.label`)\r\n optionalText(field.description, `${label}.description`)\r\n optionalBoolean(field.required, `${label}.required`)\r\n if (field.kind === 'text') {\r\n optionalBoolean(field.multiline, `${label}.multiline`)\r\n lengthBounds(field.minLength, field.maxLength, label)\r\n } else if (field.kind === 'select') {\r\n optionalBoolean(field.multiple, `${label}.multiple`)\r\n if (!Array.isArray(field.options) || field.options.length === 0) throw new TypeError(`${label}.options must be a non-empty array`)\r\n const options = new Set<string>()\r\n for (const [optionIndex, optionValue] of field.options.entries()) {\r\n const optionLabel = `${label}.options[${optionIndex}]`\r\n const option = exactRecord(optionValue, ['id', 'label', 'description'], ['id', 'label'], optionLabel)\r\n localId(option.id, `${optionLabel}.id`)\r\n if (options.has(option.id as string)) throw new TypeError(`${label} contains duplicate option id`)\r\n options.add(option.id as string)\r\n nonEmpty(option.label, `${optionLabel}.label`)\r\n optionalText(option.description, `${optionLabel}.description`)\r\n }\r\n } else if (field.kind !== 'confirm') {\r\n throw new TypeError(`${label}.kind is invalid`)\r\n }\r\n }\r\n}\r\n\r\nfunction validateApprovalRequest(value: unknown): asserts value is ApprovalRequest {\r\n const request = requestRecord(value, ['kind', 'action', 'summary', 'details', 'risk'], 'Approval request')\r\n if (request.kind !== 'approval') throw new TypeError('Approval request.kind must be \"approval\"')\r\n nonEmpty(request.action, 'Approval request.action')\r\n nonEmpty(request.summary, 'Approval request.summary')\r\n if (request.risk !== undefined && request.risk !== 'low' && request.risk !== 'medium' && request.risk !== 'high') {\r\n throw new TypeError('Approval request.risk is invalid')\r\n }\r\n if (request.details !== undefined) {\r\n if (!Array.isArray(request.details)) throw new TypeError('Approval request.details must be an array')\r\n for (const [index, detailValue] of request.details.entries()) {\r\n const label = `Approval request.details[${index}]`\r\n const detail = exactRecord(detailValue, ['label', 'value', 'sensitivity'], ['label', 'value'], label)\r\n nonEmpty(detail.label, `${label}.label`)\r\n nonEmpty(detail.value, `${label}.value`)\r\n if (detail.sensitivity !== undefined && detail.sensitivity !== 'public' && detail.sensitivity !== 'private') {\r\n throw new TypeError(`${label}.sensitivity is invalid`)\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction validateSecretInputRequest(value: unknown): asserts value is SecretInputRequest {\r\n const request = requestRecord(value, ['kind', 'label', 'description', 'minLength', 'maxLength'], 'SecretInput request')\r\n if (request.kind !== 'secret-input') throw new TypeError('SecretInput request.kind must be \"secret-input\"')\r\n nonEmpty(request.label, 'SecretInput request.label')\r\n optionalText(request.description, 'SecretInput request.description')\r\n lengthBounds(request.minLength, request.maxLength, 'SecretInput request')\r\n}\r\n\r\nfunction validateInteractionResult(\r\n request: UserInteractionRequest,\r\n value: unknown,\r\n): PresentationResult<UserInteractionValue> {\r\n if (request.kind === 'question') return validatePresentationResult(value, result => validateQuestionAnswers(request, result), 'Question result')\r\n if (request.kind === 'approval') return validatePresentationResult(value, validateApprovalValue, 'Approval result')\r\n return validatePresentationResult(value, result => validateSecretInputValue(request, result), 'SecretInput result')\r\n}\r\n\r\nfunction validateQuestionAnswers(request: QuestionRequest, value: unknown): QuestionAnswers {\r\n const result = exactRecord(value, ['answers'], ['answers'], 'Question answers')\r\n if (!record(result.answers)) throw new TypeError('Question answers.answers must be an object')\r\n const fields = new Map(request.fields.map(field => [field.id, field]))\r\n for (const field of request.fields) {\r\n if (field.required === true && !Object.hasOwn(result.answers, field.id)) throw new TypeError(`Question answers is missing required field ${JSON.stringify(field.id)}`)\r\n }\r\n for (const [id, answer] of Object.entries(result.answers)) {\r\n const field = fields.get(id)\r\n if (field === undefined) throw new TypeError(`Question answers contains unknown field ${JSON.stringify(id)}`)\r\n if (field.kind === 'text') {\r\n if (typeof answer !== 'string') throw new TypeError(`Question answer ${JSON.stringify(id)} must be a string`)\r\n if (field.minLength !== undefined && answer.length < field.minLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too short`)\r\n if (field.maxLength !== undefined && answer.length > field.maxLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too long`)\r\n } else if (field.kind === 'confirm') {\r\n if (typeof answer !== 'boolean') throw new TypeError(`Question answer ${JSON.stringify(id)} must be boolean`)\r\n } else {\r\n const allowed = new Set(field.options.map(option => option.id))\r\n const selected = field.multiple === true ? answer : [answer]\r\n if (!Array.isArray(selected) || selected.some(option => typeof option !== 'string' || !allowed.has(option))) {\r\n throw new TypeError(`Question answer ${JSON.stringify(id)} contains an invalid option`)\r\n }\r\n }\r\n }\r\n return freezeClone(value as QuestionAnswers)\r\n}\r\n\r\nfunction validateApprovalValue(value: unknown): ApprovalValue {\r\n const result = exactRecord(value, ['decision'], ['decision'], 'Approval value')\r\n if (result.decision !== 'approved' && result.decision !== 'denied') throw new TypeError('Approval value.decision is invalid')\r\n return freezeClone(value as ApprovalValue)\r\n}\r\n\r\nfunction validateSecretInputValue(request: SecretInputRequest, value: unknown): SecretInputValue {\r\n const result = exactRecord(value, ['secret'], ['secret'], 'SecretInput value')\r\n if (typeof result.secret !== 'string') throw new TypeError('SecretInput value.secret must be a string')\r\n if (request.minLength !== undefined && result.secret.length < request.minLength) throw new TypeError('SecretInput value.secret is too short')\r\n if (request.maxLength !== undefined && result.secret.length > request.maxLength) throw new TypeError('SecretInput value.secret is too long')\r\n return freezeClone(value as SecretInputValue)\r\n}\r\n\r\nfunction validatePresentationResult<T>(\r\n value: unknown,\r\n validateSubmitted: (submitted: unknown) => T,\r\n label: string,\r\n): PresentationResult<T> {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n if (value.status === 'submitted') {\r\n const result = exactRecord(value, ['status', 'value'], ['status', 'value'], label)\r\n return deepFreeze({ status: 'submitted' as const, value: validateSubmitted(result.value) })\r\n }\r\n if (value.status === 'unavailable') {\r\n const result = exactRecord(value, ['status', 'reason'], ['status'], label)\r\n optionalText(result.reason, `${label}.reason`)\r\n return freezeClone(value as PresentationResult<T>)\r\n }\r\n if (value.status === 'cancelled' || value.status === 'expired') {\r\n exactRecord(value, ['status'], ['status'], label)\r\n return freezeClone(value as PresentationResult<T>)\r\n }\r\n throw new TypeError(`${label}.status is invalid`)\r\n}\r\n\r\nfunction validateAcceptedReceipt(value: unknown): { readonly accepted: true } {\r\n const receipt = exactRecord(value, ['accepted'], ['accepted'], 'Presentation receipt')\r\n if (receipt.accepted !== true) throw new TypeError('Presentation receipt.accepted must be true')\r\n return Object.freeze({ accepted: true })\r\n}\r\n\r\nfunction requestRecord(value: unknown, fields: readonly string[], label: string): Record<string, unknown> {\r\n const required = ['requestId', 'invocationId', 'origin', ...fields.filter(field => !['title', 'description', 'details', 'risk', 'level', 'deduplicationKey', 'sensitivity', 'minLength', 'maxLength'].includes(field))]\r\n const request = exactRecord(value, ['requestId', 'invocationId', 'origin', 'deadline', ...fields], required, label)\r\n nonEmpty(request.requestId, `${label}.requestId`)\r\n nonEmpty(request.invocationId, `${label}.invocationId`)\r\n nonEmpty(request.origin, `${label}.origin`)\r\n if (request.deadline !== undefined && (typeof request.deadline !== 'string' || Number.isNaN(Date.parse(request.deadline)))) {\r\n throw new TypeError(`${label}.deadline must be an RFC 3339 date-time`)\r\n }\r\n return request\r\n}\r\n\r\nfunction validateLimits(value: unknown): UserInteractionLimits {\r\n const limits = exactRecord(\r\n value,\r\n ['maxConcurrentRequests', 'maxFields', 'maxOptionsPerField', 'maxTextLength'],\r\n [],\r\n 'UserInteraction limits',\r\n )\r\n for (const [name, limit] of Object.entries(limits)) positiveInteger(limit, `UserInteraction limits.${name}`)\r\n return freezeClone(value as UserInteractionLimits)\r\n}\r\n\r\nfunction operationList(value: unknown, label: string): readonly UserInteractionOperation[] {\r\n if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)\r\n const operations = value.map(operation => {\r\n if (operation !== 'question' && operation !== 'approval' && operation !== 'secret-input') throw new TypeError(`${label} contains an invalid operation`)\r\n return operation\r\n })\r\n if (new Set(operations).size !== operations.length) throw new TypeError(`${label} contains a duplicate operation`)\r\n return Object.freeze(operations)\r\n}\r\n\r\nfunction lengthBounds(minimum: unknown, maximum: unknown, label: string): void {\r\n if (minimum !== undefined) nonNegativeInteger(minimum, `${label}.minLength`)\r\n if (maximum !== undefined) nonNegativeInteger(maximum, `${label}.maxLength`)\r\n if (typeof minimum === 'number' && typeof maximum === 'number' && minimum > maximum) {\r\n throw new TypeError(`${label}.minLength must not exceed maxLength`)\r\n }\r\n}\r\n\r\nfunction exactRecord(value: unknown, allowed: readonly string[], required: readonly string[], label: string): Record<string, unknown> {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n const unknown = Object.keys(value).filter(key => !allowed.includes(key))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`)\r\n return value\r\n}\r\n\r\nfunction record(value: unknown): value is Record<string, unknown> {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value)\r\n}\r\n\r\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n\r\nfunction validateInvocationScope(scope: PresentationInvocationScope): void {\r\n if (!record(scope)) throw new TypeError('Presentation invocation scope must be an object')\r\n nonEmpty(scope.invocationId, 'Presentation invocation scope.invocationId')\r\n nonEmpty(scope.origin, 'Presentation invocation scope.origin')\r\n if (scope.deadline !== undefined && (typeof scope.deadline !== 'string' || Number.isNaN(Date.parse(scope.deadline)))) {\r\n throw new TypeError('Presentation invocation scope.deadline must be an RFC 3339 date-time')\r\n }\r\n if (typeof scope.nextRequestId !== 'function') throw new TypeError('Presentation invocation scope.nextRequestId must be a function')\r\n}\r\n\r\nfunction requestFactory(scope: PresentationInvocationScope) {\r\n validateInvocationScope(scope)\r\n return <T extends object>(input: T): Readonly<T & PresentationRequestContext> => {\r\n if (!record(input)) throw new TypeError('Presentation input must be an object')\r\n const requestId = scope.nextRequestId()\r\n nonEmpty(requestId, 'Presentation requestId')\r\n return freezeClone({\r\n ...input,\r\n requestId,\r\n invocationId: scope.invocationId,\r\n origin: scope.origin,\r\n ...(scope.deadline === undefined ? {} : { deadline: scope.deadline }),\r\n })\r\n }\r\n}\r\n\r\nfunction optionalText(value: unknown, label: string): void {\r\n if (value !== undefined) nonEmpty(value, label)\r\n}\r\n\r\nfunction optionalBoolean(value: unknown, label: string): void {\r\n if (value !== undefined && typeof value !== 'boolean') throw new TypeError(`${label} must be boolean`)\r\n}\r\n\r\nfunction localId(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]*$/u.test(value)) throw new TypeError(`${label} is invalid`)\r\n}\r\n\r\nfunction positiveInteger(value: unknown, label: string): void {\r\n if (!Number.isSafeInteger(value) || (value as number) < 1) throw new TypeError(`${label} must be a positive safe integer`)\r\n}\r\n\r\nfunction nonNegativeInteger(value: unknown, label: string): void {\r\n if (!Number.isSafeInteger(value) || (value as number) < 0) throw new TypeError(`${label} must be a non-negative safe integer`)\r\n}\r\n\r\nfunction freezeClone<T>(value: T): T { return deepFreeze(structuredClone(value)) }\r\n\r\nfunction deepFreeze<T>(value: T): T {\r\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return value\r\n Object.freeze(value)\r\n for (const child of Object.values(value)) deepFreeze(child)\r\n return value\r\n}\r\n"],"mappings":";;;AAoBA,MAAa,cAAc;AAC3B,MAAa,q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AAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\n ProtocolCatalog,\n ProtocolDefinition,\n ProtocolIssue,\n ProtocolNegotiationInput,\n ProtocolRequirement,\n ProtocolSupport,\n} from '@dsh-std/core'\nimport type {\n CapabilityClient,\n CapabilityHandlerContext,\n CapabilityImplementation,\n ConnectionNegotiationPolicy,\n} from '@dsh-std/connection'\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\nimport { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectProtocol } from './callback.js'\nimport type { ExternalRedirectClient } from './callback.js'\n\nexport * from './callback.js'\n\nexport const API_VERSION = 'presentation.dsh/v1alpha1'\nexport const OPEN_EXTERNAL_KIND = 'OpenExternal'\nexport const COPY_TEXT_KIND = 'CopyText'\nexport const NOTIFICATION_KIND = 'Notification'\nexport const USER_INTERACTION_KIND = 'UserInteraction'\n\nexport interface PresentationDescriptor {\n /** Endpoint identity selected and authenticated by the Host for this invocation. */\n readonly clientId: string\n /** Active Presentation agreements projected into this invocation. */\n readonly contracts: readonly ProtocolSupport[]\n}\n\nexport interface PresentationRequestContext {\n readonly requestId: string\n readonly invocationId: string\n readonly origin: string\n readonly deadline?: string\n}\n\n/** Invocation authority supplied by the Host when it creates scoped clients. */\nexport interface PresentationInvocationScope {\n readonly invocationId: string\n readonly origin: string\n readonly deadline?: string\n nextRequestId(): string\n}\n\nexport type PresentationResult<T> =\n | { readonly status: 'submitted'; readonly value: T }\n | { readonly status: 'cancelled' }\n | { readonly status: 'expired' }\n | { readonly status: 'unavailable'; readonly reason?: string }\n\nexport interface OpenExternalRequest extends PresentationRequestContext {\n readonly uri: string\n}\n\nexport type OpenExternalInput = Omit<OpenExternalRequest, keyof PresentationRequestContext>\n\nexport interface OpenExternalReceipt { readonly accepted: true }\n\nexport interface CopyTextRequest extends PresentationRequestContext {\n readonly text: string\n readonly sensitivity?: 'public' | 'private'\n}\n\nexport type CopyTextInput = Omit<CopyTextRequest, keyof PresentationRequestContext>\n\nexport interface CopyTextReceipt { readonly accepted: true }\n\nexport interface NotificationRequest extends PresentationRequestContext {\n readonly text: string\n readonly level?: 'info' | 'warning' | 'error'\n readonly deduplicationKey?: string\n}\n\nexport type NotificationInput = Omit<NotificationRequest, keyof PresentationRequestContext>\n\nexport interface NotificationReceipt { readonly accepted: true }\n\nexport type UserInteractionOperation = 'question' | 'approval' | 'secret-input'\n\nexport interface UserInteractionRequirementSpec {\n readonly operations: readonly UserInteractionOperation[]\n readonly optionalOperations?: readonly UserInteractionOperation[]\n}\n\nexport interface UserInteractionLimits {\n readonly maxConcurrentRequests?: number\n readonly maxFields?: number\n readonly maxOptionsPerField?: number\n readonly maxTextLength?: number\n}\n\nexport interface UserInteractionSupportSpec {\n readonly operations: readonly UserInteractionOperation[]\n readonly limits?: UserInteractionLimits\n}\n\nexport interface QuestionOption {\n readonly id: string\n readonly label: string\n readonly description?: string\n}\n\ninterface QuestionFieldBase {\n readonly id: string\n readonly label: string\n readonly description?: string\n readonly required?: boolean\n}\n\nexport interface TextQuestionField extends QuestionFieldBase {\n readonly kind: 'text'\n readonly multiline?: boolean\n readonly minLength?: number\n readonly maxLength?: number\n}\n\nexport interface SelectQuestionField extends QuestionFieldBase {\n readonly kind: 'select'\n readonly multiple?: boolean\n readonly options: readonly QuestionOption[]\n}\n\nexport interface ConfirmQuestionField extends QuestionFieldBase {\n readonly kind: 'confirm'\n}\n\nexport type QuestionField = TextQuestionField | SelectQuestionField | ConfirmQuestionField\n\nexport interface QuestionRequest extends PresentationRequestContext {\n readonly kind: 'question'\n readonly title?: string\n readonly description?: string\n readonly fields: readonly QuestionField[]\n}\n\nexport interface QuestionAnswers {\n readonly answers: Readonly<Record<string, string | boolean | readonly string[]>>\n}\n\nexport interface ApprovalDetail {\n readonly label: string\n readonly value: string\n readonly sensitivity?: 'public' | 'private'\n}\n\nexport interface ApprovalRequest extends PresentationRequestContext {\n readonly kind: 'approval'\n readonly action: string\n readonly summary: string\n readonly details?: readonly ApprovalDetail[]\n readonly risk?: 'low' | 'medium' | 'high'\n}\n\nexport interface ApprovalValue { readonly decision: 'approved' | 'denied' }\n\nexport interface SecretInputRequest extends PresentationRequestContext {\n readonly kind: 'secret-input'\n readonly label: string\n readonly description?: string\n readonly minLength?: number\n readonly maxLength?: number\n}\n\nexport interface SecretInputValue { readonly secret: string }\n\nexport type UserInteractionRequest = QuestionRequest | ApprovalRequest | SecretInputRequest\nexport type UserInteractionValue = QuestionAnswers | ApprovalValue | SecretInputValue\nexport type QuestionInput = Omit<QuestionRequest, keyof PresentationRequestContext>\nexport type ApprovalInput = Omit<ApprovalRequest, keyof PresentationRequestContext>\nexport type SecretInput = Omit<SecretInputRequest, keyof PresentationRequestContext>\n\nexport interface OpenExternalClient {\n openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<OpenExternalReceipt>>\n}\n\nexport interface CopyTextClient {\n copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<CopyTextReceipt>>\n}\n\nexport interface NotificationClient {\n notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<NotificationReceipt>>\n}\n\nexport interface UserInteractionClient {\n interact(input: QuestionInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<QuestionAnswers>>\n interact(input: ApprovalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<ApprovalValue>>\n interact(input: SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<SecretInputValue>>\n}\n\n/** Typed Presentation capabilities available to one domain invocation. */\nexport interface PresentationClients {\n readonly descriptor: PresentationDescriptor\n readonly openExternal?: OpenExternalClient\n readonly copyText?: CopyTextClient\n readonly notification?: NotificationClient\n readonly interaction?: UserInteractionClient\n readonly externalRedirect?: ExternalRedirectClient\n}\n\nexport interface OpenExternalHandler {\n openExternal(request: OpenExternalRequest, context: CapabilityHandlerContext): PresentationResult<OpenExternalReceipt> | Promise<PresentationResult<OpenExternalReceipt>>\n}\n\nexport interface CopyTextHandler {\n copyText(request: CopyTextRequest, context: CapabilityHandlerContext): PresentationResult<CopyTextReceipt> | Promise<PresentationResult<CopyTextReceipt>>\n}\n\nexport interface NotificationHandler {\n notify(request: NotificationRequest, context: CapabilityHandlerContext): PresentationResult<NotificationReceipt> | Promise<PresentationResult<NotificationReceipt>>\n}\n\nexport interface UserInteractionHandler {\n interact(request: QuestionRequest, context: CapabilityHandlerContext): PresentationResult<QuestionAnswers> | Promise<PresentationResult<QuestionAnswers>>\n interact(request: ApprovalRequest, context: CapabilityHandlerContext): PresentationResult<ApprovalValue> | Promise<PresentationResult<ApprovalValue>>\n interact(request: SecretInputRequest, context: CapabilityHandlerContext): PresentationResult<SecretInputValue> | Promise<PresentationResult<SecretInputValue>>\n}\n\nconst emptySpec = (value: unknown): undefined => {\n if (value !== undefined) throw new TypeError('Presentation operation does not accept spec in v1alpha1')\n return undefined\n}\n\nexport const openExternalProtocol = defineCapabilityProtocol({\n apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\n})\nexport const copyTextProtocol = defineCapabilityProtocol({\n apiVersion: API_VERSION, kind: COPY_TEXT_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\n})\nexport const notificationProtocol = defineCapabilityProtocol({\n apiVersion: API_VERSION, kind: NOTIFICATION_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\n})\n\nexport const openExternalSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND })\nexport const copyTextSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: COPY_TEXT_KIND })\nexport const notificationSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: NOTIFICATION_KIND })\nexport const userInteractionSupport = (spec: UserInteractionSupportSpec): ProtocolSupport<UserInteractionSupportSpec> =>\n Object.freeze({ apiVersion: API_VERSION, kind: USER_INTERACTION_KIND, spec: validateUserInteractionSupport(spec) })\n\nexport const userInteractionProtocol: ProtocolDefinition<\n UserInteractionRequirementSpec,\n UserInteractionSupportSpec\n> = Object.freeze({\n apiVersion: API_VERSION,\n kind: USER_INTERACTION_KIND,\n validateRequirement: validateUserInteractionRequirement,\n validateSupport: validateUserInteractionSupport,\n negotiate: negotiateUserInteraction,\n})\n\nexport const protocols: readonly ProtocolDefinition[] = Object.freeze([\n openExternalProtocol,\n copyTextProtocol,\n notificationProtocol,\n userInteractionProtocol,\n externalRedirectProtocol,\n])\n\nexport function register(catalog: ProtocolCatalog): () => void {\n const disposers = protocols.map(protocol => catalog.register(protocol))\n return () => { for (const dispose of disposers.reverse()) dispose() }\n}\n\nexport function openExternalClient(client: CapabilityClient, scope: PresentationInvocationScope): OpenExternalClient {\n const request = requestFactory(scope)\n return Object.freeze({\n async openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }) {\n const value = request(input)\n validateOpenExternalRequest(value)\n const result = await client.invoke<OpenExternalRequest, PresentationResult<OpenExternalReceipt>>(\n openExternalSupport, 'openExternal', value, options,\n ).result\n return validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result')\n },\n })\n}\n\nexport function copyTextClient(client: CapabilityClient, scope: PresentationInvocationScope): CopyTextClient {\n const request = requestFactory(scope)\n return Object.freeze({\n async copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }) {\n const value = request(input)\n validateCopyTextRequest(value)\n const result = await client.invoke<CopyTextRequest, PresentationResult<CopyTextReceipt>>(\n copyTextSupport, 'copyText', value, options,\n ).result\n return validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result')\n },\n })\n}\n\nexport function notificationClient(client: CapabilityClient, scope: PresentationInvocationScope): NotificationClient {\n const request = requestFactory(scope)\n return Object.freeze({\n async notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }) {\n const value = request(input)\n validateNotificationRequest(value)\n const result = await client.invoke<NotificationRequest, PresentationResult<NotificationReceipt>>(\n notificationSupport, 'notify', value, options,\n ).result\n return validatePresentationResult(result, validateAcceptedReceipt, 'Notification result')\n },\n })\n}\n\nexport function userInteractionClient(client: CapabilityClient, scope: PresentationInvocationScope): UserInteractionClient {\n const request = requestFactory(scope)\n return Object.freeze({\n async interact(input: QuestionInput | ApprovalInput | SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<UserInteractionValue>> {\n const value = request(input) as UserInteractionRequest\n validateUserInteractionRequest(value)\n const result = await client.invoke<UserInteractionRequest, PresentationResult<UserInteractionValue>>(\n { apiVersion: API_VERSION, kind: USER_INTERACTION_KIND }, 'interact', value, options,\n ).result\n return validateInteractionResult(value, result)\n },\n }) as UserInteractionClient\n}\n\nexport function presentationClients(\n descriptor: PresentationDescriptor,\n client: CapabilityClient,\n scope: PresentationInvocationScope,\n): PresentationClients {\n validatePresentationDescriptor(descriptor)\n validateInvocationScope(scope)\n const has = (kind: string) => descriptor.contracts.some(contract =>\n contract.apiVersion === API_VERSION && contract.kind === kind && client.binding(contract) !== undefined)\n return Object.freeze({\n descriptor: freezeClone(descriptor),\n ...(has(OPEN_EXTERNAL_KIND) ? { openExternal: openExternalClient(client, scope) } : {}),\n ...(has(COPY_TEXT_KIND) ? { copyText: copyTextClient(client, scope) } : {}),\n ...(has(NOTIFICATION_KIND) ? { notification: notificationClient(client, scope) } : {}),\n ...(has(USER_INTERACTION_KIND) ? { interaction: userInteractionClient(client, scope) } : {}),\n ...(has(EXTERNAL_REDIRECT_KIND) ? { externalRedirect: externalRedirectClient(client, scope) } : {}),\n })\n}\n\nexport function openExternalImplementation(participantId: string, handler: OpenExternalHandler): CapabilityImplementation {\n return implementation(participantId, openExternalSupport, 'openExternal', validateOpenExternalRequest, handler.openExternal.bind(handler),\n result => validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result'))\n}\n\nexport function copyTextImplementation(participantId: string, handler: CopyTextHandler): CapabilityImplementation {\n return implementation(participantId, copyTextSupport, 'copyText', validateCopyTextRequest, handler.copyText.bind(handler),\n result => validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result'))\n}\n\nexport function notificationImplementation(participantId: string, handler: NotificationHandler): CapabilityImplementation {\n return implementation(participantId, notificationSupport, 'notify', validateNotificationRequest, handler.notify.bind(handler),\n result => validatePresentationResult(result, validateAcceptedReceipt, 'Notification result'))\n}\n\nexport function userInteractionImplementation(\n participantId: string,\n spec: UserInteractionSupportSpec,\n handler: UserInteractionHandler,\n): CapabilityImplementation {\n const protocol = userInteractionSupport(spec)\n return Object.freeze({\n participantId,\n protocol,\n async handle(operationName: string, input: unknown, context: CapabilityHandlerContext) {\n if (operationName !== 'interact') throw new TypeError(`unsupported UserInteraction operation ${JSON.stringify(operationName)}`)\n validateUserInteractionRequest(input)\n if (!spec.operations.includes(input.kind)) throw new TypeError(`UserInteraction provider does not support ${JSON.stringify(input.kind)}`)\n const result = await handler.interact(input as never, context)\n return validateInteractionResult(input, result)\n },\n })\n}\n\nexport function validatePresentationDescriptor(value: unknown): asserts value is PresentationDescriptor {\n const descriptor = exactRecord(value, ['clientId', 'contracts'], ['clientId', 'contracts'], 'Presentation descriptor')\n nonEmpty(descriptor.clientId, 'Presentation descriptor.clientId')\n if (!Array.isArray(descriptor.contracts)) throw new TypeError('Presentation descriptor.contracts must be an array')\n const seen = new Set<string>()\n for (const [index, contractValue] of descriptor.contracts.entries()) {\n const contract = exactRecord(contractValue, ['apiVersion', 'kind', 'spec'], ['apiVersion', 'kind'], `Presentation descriptor.contracts[${index}]`)\n nonEmpty(contract.apiVersion, `Presentation descriptor.contracts[${index}].apiVersion`)\n nonEmpty(contract.kind, `Presentation descriptor.contracts[${index}].kind`)\n const key = `${String(contract.apiVersion)}\\0${String(contract.kind)}`\n if (seen.has(key)) throw new TypeError(`Presentation descriptor contains duplicate contract ${JSON.stringify(key)}`)\n seen.add(key)\n }\n}\n\nexport function validateOpenExternalRequest(value: unknown): asserts value is OpenExternalRequest {\n const request = requestRecord(value, ['uri'], 'OpenExternal request')\n nonEmpty(request.uri, 'OpenExternal request.uri')\n const uri = new URL(request.uri as string)\n if (uri.protocol !== 'https:' && uri.protocol !== 'http:') throw new TypeError('OpenExternal only accepts HTTP(S) URIs')\n}\n\nexport function validateCopyTextRequest(value: unknown): asserts value is CopyTextRequest {\n const request = requestRecord(value, ['text', 'sensitivity'], 'CopyText request')\n nonEmpty(request.text, 'CopyText request.text')\n if (request.sensitivity !== undefined && request.sensitivity !== 'public' && request.sensitivity !== 'private') {\n throw new TypeError('CopyText request.sensitivity is invalid')\n }\n}\n\nexport function validateNotificationRequest(value: unknown): asserts value is NotificationRequest {\n const request = requestRecord(value, ['text', 'level', 'deduplicationKey'], 'Notification request')\n nonEmpty(request.text, 'Notification request.text')\n if (request.level !== undefined && request.level !== 'info' && request.level !== 'warning' && request.level !== 'error') {\n throw new TypeError('Notification request.level is invalid')\n }\n if (request.deduplicationKey !== undefined) nonEmpty(request.deduplicationKey, 'Notification request.deduplicationKey')\n}\n\nexport function validateUserInteractionRequest(value: unknown): asserts value is UserInteractionRequest {\n if (!record(value)) throw new TypeError('UserInteraction request must be an object')\n if (value.kind === 'question') return validateQuestionRequest(value)\n if (value.kind === 'approval') return validateApprovalRequest(value)\n if (value.kind === 'secret-input') return validateSecretInputRequest(value)\n throw new TypeError('UserInteraction request.kind is invalid')\n}\n\nexport function validateUserInteractionRequirement(value: unknown): UserInteractionRequirementSpec {\n const spec = exactRecord(value, ['operations', 'optionalOperations'], ['operations'], 'UserInteraction requirement spec')\n const operations = operationList(spec.operations, 'UserInteraction requirement spec.operations')\n const optionalOperations = spec.optionalOperations === undefined\n ? undefined\n : operationList(spec.optionalOperations, 'UserInteraction requirement spec.optionalOperations')\n if (optionalOperations?.some(operation => operations.includes(operation)) === true) {\n throw new TypeError('UserInteraction optionalOperations must not duplicate required operations')\n }\n return deepFreeze({ operations, ...(optionalOperations === undefined ? {} : { optionalOperations }) })\n}\n\nexport function validateUserInteractionSupport(value: unknown): UserInteractionSupportSpec {\n const spec = exactRecord(value, ['operations', 'limits'], ['operations'], 'UserInteraction support spec')\n const operations = operationList(spec.operations, 'UserInteraction support spec.operations')\n const limits = spec.limits === undefined ? undefined : validateLimits(spec.limits)\n return deepFreeze({ operations, ...(limits === undefined ? {} : { limits }) })\n}\n\nfunction negotiateUserInteraction(\n input: ProtocolNegotiationInput<UserInteractionRequirementSpec, UserInteractionSupportSpec>,\n) {\n const issues: ProtocolIssue[] = []\n const bindings: Array<{\n readonly consumer: string\n readonly provider: string\n readonly requirement: ProtocolRequirement<UserInteractionRequirementSpec>\n readonly support: ProtocolSupport<UserInteractionSupportSpec>\n }> = []\n const connectionPolicy = connectionNegotiationPolicy(input.policy)\n for (const row of input.requirements) {\n const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant]\n const candidates = input.supports.filter(candidate => {\n if (candidate.participant === row.participant) return false\n if (consumerEndpoint !== undefined && connectionPolicy?.endpointByParticipant[candidate.participant] === consumerEndpoint) return false\n return row.requirement.spec!.operations.every(operation => candidate.support.spec!.operations.includes(operation))\n })\n if (candidates.length === 0) {\n issues.push(Object.freeze({\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\n severity: row.requirement.optional === true ? 'warning' : 'error',\n participant: row.participant,\n message: `no participant supports the required ${USER_INTERACTION_KIND} operations`,\n }))\n continue\n }\n if (candidates.length > 1) {\n issues.push(Object.freeze({\n code: 'support-ambiguous', severity: 'error', participant: row.participant,\n message: `multiple participants support ${API_VERSION} ${USER_INTERACTION_KIND}`,\n }))\n continue\n }\n const provider = candidates[0]!\n bindings.push(Object.freeze({\n consumer: row.participant,\n provider: provider.participant,\n requirement: row.requirement,\n support: provider.support,\n }))\n for (const operation of row.requirement.spec!.optionalOperations ?? []) {\n if (provider.support.spec!.operations.includes(operation)) continue\n issues.push(Object.freeze({\n code: 'optional-operation-missing', severity: 'warning', participant: row.participant,\n message: `${USER_INTERACTION_KIND} provider does not support optional operation ${JSON.stringify(operation)}`,\n }))\n }\n }\n return {\n agreement: Object.freeze({ kind: 'CapabilityBindings' as const, bindings: Object.freeze(bindings) }),\n issues: Object.freeze(issues),\n }\n}\n\nfunction connectionNegotiationPolicy(value: unknown): ConnectionNegotiationPolicy | undefined {\n return record(value) && record(value.endpointByParticipant)\n ? value as unknown as ConnectionNegotiationPolicy\n : undefined\n}\n\nfunction implementation<TInput, TOutput>(\n participantId: string,\n protocol: ProtocolSupport,\n operationName: string,\n validateInput: (value: unknown) => asserts value is TInput,\n handler: (input: TInput, context: CapabilityHandlerContext) => TOutput | Promise<TOutput>,\n validateOutput: (value: unknown) => TOutput,\n): CapabilityImplementation {\n return Object.freeze({\n participantId,\n protocol,\n async handle(operation: string, input: unknown, context: CapabilityHandlerContext) {\n if (operation !== operationName) throw new TypeError(`unsupported ${protocol.kind} operation ${JSON.stringify(operation)}`)\n validateInput(input)\n return validateOutput(await handler(input, context))\n },\n })\n}\n\nfunction validateQuestionRequest(value: unknown): asserts value is QuestionRequest {\n const request = requestRecord(value, ['kind', 'title', 'description', 'fields'], 'Question request')\n if (request.kind !== 'question') throw new TypeError('Question request.kind must be \"question\"')\n optionalText(request.title, 'Question request.title')\n optionalText(request.description, 'Question request.description')\n if (!Array.isArray(request.fields) || request.fields.length === 0) throw new TypeError('Question request.fields must be a non-empty array')\n const ids = new Set<string>()\n for (const [index, fieldValue] of request.fields.entries()) {\n const label = `Question request.fields[${index}]`\n if (!record(fieldValue)) throw new TypeError(`${label} must be an object`)\n const common = ['id', 'kind', 'label', 'description', 'required']\n const allowed = fieldValue.kind === 'text' ? [...common, 'multiline', 'minLength', 'maxLength']\n : fieldValue.kind === 'select' ? [...common, 'multiple', 'options'] : common\n const field = exactRecord(fieldValue, allowed, ['id', 'kind', 'label'], label)\n localId(field.id, `${label}.id`)\n if (ids.has(field.id as string)) throw new TypeError('Question request contains duplicate field id')\n ids.add(field.id as string)\n nonEmpty(field.label, `${label}.label`)\n optionalText(field.description, `${label}.description`)\n optionalBoolean(field.required, `${label}.required`)\n if (field.kind === 'text') {\n optionalBoolean(field.multiline, `${label}.multiline`)\n lengthBounds(field.minLength, field.maxLength, label)\n } else if (field.kind === 'select') {\n optionalBoolean(field.multiple, `${label}.multiple`)\n if (!Array.isArray(field.options) || field.options.length === 0) throw new TypeError(`${label}.options must be a non-empty array`)\n const options = new Set<string>()\n for (const [optionIndex, optionValue] of field.options.entries()) {\n const optionLabel = `${label}.options[${optionIndex}]`\n const option = exactRecord(optionValue, ['id', 'label', 'description'], ['id', 'label'], optionLabel)\n localId(option.id, `${optionLabel}.id`)\n if (options.has(option.id as string)) throw new TypeError(`${label} contains duplicate option id`)\n options.add(option.id as string)\n nonEmpty(option.label, `${optionLabel}.label`)\n optionalText(option.description, `${optionLabel}.description`)\n }\n } else if (field.kind !== 'confirm') {\n throw new TypeError(`${label}.kind is invalid`)\n }\n }\n}\n\nfunction validateApprovalRequest(value: unknown): asserts value is ApprovalRequest {\n const request = requestRecord(value, ['kind', 'action', 'summary', 'details', 'risk'], 'Approval request')\n if (request.kind !== 'approval') throw new TypeError('Approval request.kind must be \"approval\"')\n nonEmpty(request.action, 'Approval request.action')\n nonEmpty(request.summary, 'Approval request.summary')\n if (request.risk !== undefined && request.risk !== 'low' && request.risk !== 'medium' && request.risk !== 'high') {\n throw new TypeError('Approval request.risk is invalid')\n }\n if (request.details !== undefined) {\n if (!Array.isArray(request.details)) throw new TypeError('Approval request.details must be an array')\n for (const [index, detailValue] of request.details.entries()) {\n const label = `Approval request.details[${index}]`\n const detail = exactRecord(detailValue, ['label', 'value', 'sensitivity'], ['label', 'value'], label)\n nonEmpty(detail.label, `${label}.label`)\n nonEmpty(detail.value, `${label}.value`)\n if (detail.sensitivity !== undefined && detail.sensitivity !== 'public' && detail.sensitivity !== 'private') {\n throw new TypeError(`${label}.sensitivity is invalid`)\n }\n }\n }\n}\n\nfunction validateSecretInputRequest(value: unknown): asserts value is SecretInputRequest {\n const request = requestRecord(value, ['kind', 'label', 'description', 'minLength', 'maxLength'], 'SecretInput request')\n if (request.kind !== 'secret-input') throw new TypeError('SecretInput request.kind must be \"secret-input\"')\n nonEmpty(request.label, 'SecretInput request.label')\n optionalText(request.description, 'SecretInput request.description')\n lengthBounds(request.minLength, request.maxLength, 'SecretInput request')\n}\n\nfunction validateInteractionResult(\n request: UserInteractionRequest,\n value: unknown,\n): PresentationResult<UserInteractionValue> {\n if (request.kind === 'question') return validatePresentationResult(value, result => validateQuestionAnswers(request, result), 'Question result')\n if (request.kind === 'approval') return validatePresentationResult(value, validateApprovalValue, 'Approval result')\n return validatePresentationResult(value, result => validateSecretInputValue(request, result), 'SecretInput result')\n}\n\nfunction validateQuestionAnswers(request: QuestionRequest, value: unknown): QuestionAnswers {\n const result = exactRecord(value, ['answers'], ['answers'], 'Question answers')\n if (!record(result.answers)) throw new TypeError('Question answers.answers must be an object')\n const fields = new Map(request.fields.map(field => [field.id, field]))\n for (const field of request.fields) {\n if (field.required === true && !Object.hasOwn(result.answers, field.id)) throw new TypeError(`Question answers is missing required field ${JSON.stringify(field.id)}`)\n }\n for (const [id, answer] of Object.entries(result.answers)) {\n const field = fields.get(id)\n if (field === undefined) throw new TypeError(`Question answers contains unknown field ${JSON.stringify(id)}`)\n if (field.kind === 'text') {\n if (typeof answer !== 'string') throw new TypeError(`Question answer ${JSON.stringify(id)} must be a string`)\n if (field.minLength !== undefined && answer.length < field.minLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too short`)\n if (field.maxLength !== undefined && answer.length > field.maxLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too long`)\n } else if (field.kind === 'confirm') {\n if (typeof answer !== 'boolean') throw new TypeError(`Question answer ${JSON.stringify(id)} must be boolean`)\n } else {\n const allowed = new Set(field.options.map(option => option.id))\n const selected = field.multiple === true ? answer : [answer]\n if (!Array.isArray(selected) || selected.some(option => typeof option !== 'string' || !allowed.has(option))) {\n throw new TypeError(`Question answer ${JSON.stringify(id)} contains an invalid option`)\n }\n }\n }\n return freezeClone(value as QuestionAnswers)\n}\n\nfunction validateApprovalValue(value: unknown): ApprovalValue {\n const result = exactRecord(value, ['decision'], ['decision'], 'Approval value')\n if (result.decision !== 'approved' && result.decision !== 'denied') throw new TypeError('Approval value.decision is invalid')\n return freezeClone(value as ApprovalValue)\n}\n\nfunction validateSecretInputValue(request: SecretInputRequest, value: unknown): SecretInputValue {\n const result = exactRecord(value, ['secret'], ['secret'], 'SecretInput value')\n if (typeof result.secret !== 'string') throw new TypeError('SecretInput value.secret must be a string')\n if (request.minLength !== undefined && result.secret.length < request.minLength) throw new TypeError('SecretInput value.secret is too short')\n if (request.maxLength !== undefined && result.secret.length > request.maxLength) throw new TypeError('SecretInput value.secret is too long')\n return freezeClone(value as SecretInputValue)\n}\n\nfunction validatePresentationResult<T>(\n value: unknown,\n validateSubmitted: (submitted: unknown) => T,\n label: string,\n): PresentationResult<T> {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n if (value.status === 'submitted') {\n const result = exactRecord(value, ['status', 'value'], ['status', 'value'], label)\n return deepFreeze({ status: 'submitted' as const, value: validateSubmitted(result.value) })\n }\n if (value.status === 'unavailable') {\n const result = exactRecord(value, ['status', 'reason'], ['status'], label)\n optionalText(result.reason, `${label}.reason`)\n return freezeClone(value as PresentationResult<T>)\n }\n if (value.status === 'cancelled' || value.status === 'expired') {\n exactRecord(value, ['status'], ['status'], label)\n return freezeClone(value as PresentationResult<T>)\n }\n throw new TypeError(`${label}.status is invalid`)\n}\n\nfunction validateAcceptedReceipt(value: unknown): { readonly accepted: true } {\n const receipt = exactRecord(value, ['accepted'], ['accepted'], 'Presentation receipt')\n if (receipt.accepted !== true) throw new TypeError('Presentation receipt.accepted must be true')\n return Object.freeze({ accepted: true })\n}\n\nfunction requestRecord(value: unknown, fields: readonly string[], label: string): Record<string, unknown> {\n const required = ['requestId', 'invocationId', 'origin', ...fields.filter(field => !['title', 'description', 'details', 'risk', 'level', 'deduplicationKey', 'sensitivity', 'minLength', 'maxLength'].includes(field))]\n const request = exactRecord(value, ['requestId', 'invocationId', 'origin', 'deadline', ...fields], required, label)\n nonEmpty(request.requestId, `${label}.requestId`)\n nonEmpty(request.invocationId, `${label}.invocationId`)\n nonEmpty(request.origin, `${label}.origin`)\n if (request.deadline !== undefined && (typeof request.deadline !== 'string' || Number.isNaN(Date.parse(request.deadline)))) {\n throw new TypeError(`${label}.deadline must be an RFC 3339 date-time`)\n }\n return request\n}\n\nfunction validateLimits(value: unknown): UserInteractionLimits {\n const limits = exactRecord(\n value,\n ['maxConcurrentRequests', 'maxFields', 'maxOptionsPerField', 'maxTextLength'],\n [],\n 'UserInteraction limits',\n )\n for (const [name, limit] of Object.entries(limits)) positiveInteger(limit, `UserInteraction limits.${name}`)\n return freezeClone(value as UserInteractionLimits)\n}\n\nfunction operationList(value: unknown, label: string): readonly UserInteractionOperation[] {\n if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)\n const operations = value.map(operation => {\n if (operation !== 'question' && operation !== 'approval' && operation !== 'secret-input') throw new TypeError(`${label} contains an invalid operation`)\n return operation\n })\n if (new Set(operations).size !== operations.length) throw new TypeError(`${label} contains a duplicate operation`)\n return Object.freeze(operations)\n}\n\nfunction lengthBounds(minimum: unknown, maximum: unknown, label: string): void {\n if (minimum !== undefined) nonNegativeInteger(minimum, `${label}.minLength`)\n if (maximum !== undefined) nonNegativeInteger(maximum, `${label}.maxLength`)\n if (typeof minimum === 'number' && typeof maximum === 'number' && minimum > maximum) {\n throw new TypeError(`${label}.minLength must not exceed maxLength`)\n }\n}\n\nfunction exactRecord(value: unknown, allowed: readonly string[], required: readonly string[], label: string): Record<string, unknown> {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n const unknown = Object.keys(value).filter(key => !allowed.includes(key))\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\n for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`)\n return value\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\n\nfunction validateInvocationScope(scope: PresentationInvocationScope): void {\n if (!record(scope)) throw new TypeError('Presentation invocation scope must be an object')\n nonEmpty(scope.invocationId, 'Presentation invocation scope.invocationId')\n nonEmpty(scope.origin, 'Presentation invocation scope.origin')\n if (scope.deadline !== undefined && (typeof scope.deadline !== 'string' || Number.isNaN(Date.parse(scope.deadline)))) {\n throw new TypeError('Presentation invocation scope.deadline must be an RFC 3339 date-time')\n }\n if (typeof scope.nextRequestId !== 'function') throw new TypeError('Presentation invocation scope.nextRequestId must be a function')\n}\n\nfunction requestFactory(scope: PresentationInvocationScope) {\n validateInvocationScope(scope)\n return <T extends object>(input: T): Readonly<T & PresentationRequestContext> => {\n if (!record(input)) throw new TypeError('Presentation input must be an object')\n const requestId = scope.nextRequestId()\n nonEmpty(requestId, 'Presentation requestId')\n return freezeClone({\n ...input,\n requestId,\n invocationId: scope.invocationId,\n origin: scope.origin,\n ...(scope.deadline === undefined ? {} : { deadline: scope.deadline }),\n })\n }\n}\n\nfunction optionalText(value: unknown, label: string): void {\n if (value !== undefined) nonEmpty(value, label)\n}\n\nfunction optionalBoolean(value: unknown, label: string): void {\n if (value !== undefined && typeof value !== 'boolean') throw new TypeError(`${label} must be boolean`)\n}\n\nfunction localId(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]*$/u.test(value)) throw new TypeError(`${label} is invalid`)\n}\n\nfunction positiveInteger(value: unknown, label: string): void {\n if (!Number.isSafeInteger(value) || (value as number) < 1) throw new TypeError(`${label} must be a positive safe integer`)\n}\n\nfunction nonNegativeInteger(value: unknown, label: string): void {\n if (!Number.isSafeInteger(value) || (value as number) < 0) throw new TypeError(`${label} must be a non-negative safe integer`)\n}\n\nfunction freezeClone<T>(value: T): T { return deepFreeze(structuredClone(value)) }\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return value\n Object.freeze(value)\n for (const child of Object.values(value)) deepFreeze(child)\n return value\n}\n"],"mappings":";;;AAoBA,MAAa,cAAc;AAC3B,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,wBAAwB;AAqMrC,MAAM,aAAa,UAA8B;CAC/C,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,UAAU,yDAAyD;AAExG;AAEA,MAAa,uBAAuB,yBAAyB;CAC3D,YAAY;CAAa,MAAM;CAAoB,qBAAqB;CAAW,iBAAiB;AACtG,CAAC;AACD,MAAa,mBAAmB,yBAAyB;CACvD,YAAY;CAAa,MAAM;CAAgB,qBAAqB;CAAW,iBAAiB;AAClG,CAAC;AACD,MAAa,uBAAuB,yBAAyB;CAC3D,YAAY;CAAa,MAAM;CAAmB,qBAAqB;CAAW,iBAAiB;AACrG,CAAC;AAED,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAmB,CAAC;AACvH,MAAa,kBAAmC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAe,CAAC;AAC/G,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAkB,CAAC;AACtH,MAAa,0BAA0B,SACrC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;CAAuB,MAAM,+BAA+B,IAAI;AAAE,CAAC;AAEpH,MAAa,0BAGT,OAAO,OAAO;CAChB,YAAY;CACZ,MAAM;CACN,qBAAqB;CACrB,iBAAiB;CACjB,WAAW;AACb,CAAC;AAED,MAAa,YAA2C,OAAO,OAAO;CACpE;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,SAAS,SAAsC;CAC7D,MAAM,YAAY,UAAU,KAAI,aAAY,QAAQ,SAAS,QAAQ,CAAC;CACtE,aAAa;EAAE,KAAK,MAAM,WAAW,UAAU,QA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a;CAClC,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,SAAS,KAAK,GAAG,OAAO;CAClF,OAAO,OAAO,KAAK;CACnB,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,GAAG,WAAW,KAAK;CAC1D,OAAO;AACT"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dsh-std/presentation",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
10
|
-
"./operations": { "types": "./lib/operations.d.ts", "default": "./lib/operations.js" },
|
|
11
|
-
"./interaction": { "types": "./lib/interaction.d.ts", "default": "./lib/interaction.js" },
|
|
12
|
-
"./callback": { "types": "./lib/callback.d.ts", "default": "./lib/callback.js" }
|
|
13
|
-
},
|
|
14
|
-
"files": ["lib", "CHANGELOG.md"],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "pnpm run typecheck && tsdown",
|
|
17
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
-
"test": "vitest run --passWithNoTests"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@dsh-std/core": "workspace:*",
|
|
22
|
-
"@dsh-std/connection": "workspace:*"
|
|
23
|
-
},
|
|
24
|
-
"engines": { "node": "^22.19 || >=24" }
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-std/presentation",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
10
|
+
"./operations": { "types": "./lib/operations.d.ts", "default": "./lib/operations.js" },
|
|
11
|
+
"./interaction": { "types": "./lib/interaction.d.ts", "default": "./lib/interaction.js" },
|
|
12
|
+
"./callback": { "types": "./lib/callback.d.ts", "default": "./lib/callback.js" }
|
|
13
|
+
},
|
|
14
|
+
"files": ["lib", "CHANGELOG.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "pnpm run typecheck && tsdown",
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
+
"test": "vitest run --passWithNoTests"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@dsh-std/core": "workspace:*",
|
|
22
|
+
"@dsh-std/connection": "workspace:*"
|
|
23
|
+
},
|
|
24
|
+
"engines": { "node": "^22.19 || >=24" }
|
|
25
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Changes to `@dsh-std/storage` are recorded here.
|
|
4
|
-
|
|
5
|
-
## 0.1.0 (draft)
|
|
6
|
-
|
|
7
|
-
- Defined scoped local JSON storage get, set, and delete operations.
|
|
8
|
-
- Added permission names, schemas, validators, and deterministic provider negotiation.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/storage` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Defined scoped local JSON storage get, set, and delete operations.
|
|
8
|
+
- Added permission names, schemas, validators, and deterministic provider negotiation.
|