@deepseek-harness-tui/dsh-tui 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +22 -13
  2. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
  3. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
  4. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
  5. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
  6. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
  7. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
  8. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
  9. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
  10. package/dsh-ecosystem-spec/registry/README.md +14 -0
  11. package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
  12. package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
  13. package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
  14. package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
  15. package/{ecosystem-spec → dsh-ecosystem-spec}/registry/permissions-0.1.json +1 -1
  16. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
  17. package/lib/types/command-trees.d.ts +2 -1
  18. package/lib/types/command-trees.d.ts.map +1 -1
  19. package/lib/types/command-trees.js +1 -1
  20. package/lib/types/components/LoadedContextPanel.d.ts +10 -5
  21. package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
  22. package/lib/types/components/LoadedContextPanel.js +18 -7
  23. package/lib/types/components/LogoV2.d.ts.map +1 -1
  24. package/lib/types/components/LogoV2.js +16 -7
  25. package/lib/types/components/Markdown.d.ts +13 -1
  26. package/lib/types/components/Markdown.d.ts.map +1 -1
  27. package/lib/types/components/Markdown.js +15 -1
  28. package/lib/types/components/MessageList.d.ts +3 -1
  29. package/lib/types/components/MessageList.d.ts.map +1 -1
  30. package/lib/types/components/MessageList.js +90 -9
  31. package/lib/types/components/PromptInput.d.ts.map +1 -1
  32. package/lib/types/components/PromptInput.js +26 -12
  33. package/lib/types/components/StreamingMarkdown.d.ts +2 -8
  34. package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
  35. package/lib/types/components/StreamingMarkdown.js +51 -9
  36. package/lib/types/components/activityFrames.d.ts +1 -1
  37. package/lib/types/components/activityFrames.d.ts.map +1 -1
  38. package/lib/types/components/activityFrames.js +4 -1
  39. package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
  40. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
  41. package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
  42. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  43. package/lib/types/components/messages/AssistantToolUseMessage.js +12 -1
  44. package/lib/types/dsh-adapter/channel.d.ts +31 -4
  45. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  46. package/lib/types/dsh-adapter/channel.js +267 -102
  47. package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/childStderr.js +10 -0
  49. package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -1
  50. package/lib/types/dsh-adapter/command-attribution.js +2 -2
  51. package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
  52. package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
  53. package/lib/types/dsh-adapter/command-trees.js +70 -20
  54. package/lib/types/dsh-adapter/component-identity.d.ts +5 -0
  55. package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -1
  56. package/lib/types/dsh-adapter/component-identity.js +14 -14
  57. package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -1
  58. package/lib/types/dsh-adapter/decision-guard.js +10 -16
  59. package/lib/types/dsh-adapter/dialogs.d.ts +2 -3
  60. package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -1
  61. package/lib/types/dsh-adapter/dialogs.js +114 -60
  62. package/lib/types/dsh-adapter/effect-ledger.d.ts +0 -8
  63. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  64. package/lib/types/dsh-adapter/effect-ledger.js +73 -53
  65. package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -1
  66. package/lib/types/dsh-adapter/extension-events.js +39 -1
  67. package/lib/types/dsh-adapter/grants.d.ts.map +1 -1
  68. package/lib/types/dsh-adapter/grants.js +43 -14
  69. package/lib/types/dsh-adapter/host-access.d.ts +37 -0
  70. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
  71. package/lib/types/dsh-adapter/host-access.js +652 -0
  72. package/lib/types/dsh-adapter/host-descriptor.d.ts +2 -2
  73. package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -1
  74. package/lib/types/dsh-adapter/host-descriptor.js +31 -8
  75. package/lib/types/dsh-adapter/index.d.ts +4 -0
  76. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  77. package/lib/types/dsh-adapter/index.js +1 -0
  78. package/lib/types/dsh-adapter/message-observer.d.ts +10 -15
  79. package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -1
  80. package/lib/types/dsh-adapter/message-observer.js +114 -70
  81. package/lib/types/dsh-adapter/plugin-host.d.ts +39 -6
  82. package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -1
  83. package/lib/types/dsh-adapter/plugin-host.js +139 -44
  84. package/lib/types/dsh-adapter/plugin-storage.d.ts +0 -5
  85. package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/plugin-storage.js +48 -36
  87. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  88. package/lib/types/dsh-adapter/plugin.js +80 -16
  89. package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
  90. package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
  91. package/lib/types/dsh-adapter/promptDebug.js +13 -4
  92. package/lib/types/dsh-adapter/renderers.d.ts +6 -14
  93. package/lib/types/dsh-adapter/renderers.d.ts.map +1 -1
  94. package/lib/types/dsh-adapter/renderers.js +81 -46
  95. package/lib/types/dsh-adapter/scenes.d.ts +8 -4
  96. package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
  97. package/lib/types/dsh-adapter/scenes.js +136 -37
  98. package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
  99. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  100. package/lib/types/dsh-adapter/settings-sections.js +106 -26
  101. package/lib/types/dsh-adapter/shortcuts.d.ts +8 -10
  102. package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -1
  103. package/lib/types/dsh-adapter/shortcuts.js +108 -36
  104. package/lib/types/dsh-adapter/status.d.ts +6 -7
  105. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  106. package/lib/types/dsh-adapter/status.js +88 -22
  107. package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
  108. package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
  109. package/lib/types/dsh-adapter/workspaces.js +287 -170
  110. package/lib/types/extensions.d.ts +10 -5
  111. package/lib/types/extensions.d.ts.map +1 -1
  112. package/lib/types/extensions.js +11 -5
  113. package/lib/types/force-production-react.d.ts +1 -0
  114. package/lib/types/force-production-react.d.ts.map +1 -0
  115. package/lib/types/force-production-react.js +12 -0
  116. package/lib/types/i18n.d.ts +14 -6
  117. package/lib/types/i18n.d.ts.map +1 -1
  118. package/lib/types/i18n.js +4 -2
  119. package/lib/types/index.d.ts +1 -0
  120. package/lib/types/index.d.ts.map +1 -1
  121. package/lib/types/index.js +1 -0
  122. package/lib/types/ink/components/App.d.ts +2 -0
  123. package/lib/types/ink/components/App.d.ts.map +1 -1
  124. package/lib/types/ink/components/App.js +4 -0
  125. package/lib/types/ink/ink.d.ts +20 -3
  126. package/lib/types/ink/ink.d.ts.map +1 -1
  127. package/lib/types/ink/ink.js +57 -5
  128. package/lib/types/ink/log-update.d.ts.map +1 -1
  129. package/lib/types/ink/log-update.js +128 -9
  130. package/lib/types/ink/output.d.ts +28 -2
  131. package/lib/types/ink/output.d.ts.map +1 -1
  132. package/lib/types/ink/output.js +158 -12
  133. package/lib/types/ink/screen.d.ts +39 -0
  134. package/lib/types/ink/screen.d.ts.map +1 -1
  135. package/lib/types/ink/screen.js +117 -0
  136. package/lib/types/ink/terminal.d.ts.map +1 -1
  137. package/lib/types/ink/terminal.js +10 -2
  138. package/lib/types/ink/wrapAnsi.d.ts +1 -1
  139. package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
  140. package/lib/types/ink/wrapAnsi.js +29 -2
  141. package/lib/types/plugin-host.d.ts +13 -11
  142. package/lib/types/plugin-host.d.ts.map +1 -1
  143. package/lib/types/plugin-host.js +16 -16
  144. package/lib/types/plugin-spec/registry.d.ts +2 -2
  145. package/lib/types/plugin-spec/registry.d.ts.map +1 -1
  146. package/lib/types/plugin-spec/registry.js +113 -18
  147. package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -1
  148. package/lib/types/plugin-spec/tui-extension.js +2 -0
  149. package/lib/types/plugin-spec/validate.d.ts.map +1 -1
  150. package/lib/types/plugin-spec/validate.js +20 -1
  151. package/lib/types/scenes.d.ts +2 -1
  152. package/lib/types/scenes.d.ts.map +1 -1
  153. package/lib/types/scenes.js +1 -1
  154. package/lib/types/screens/Chat.d.ts +3 -3
  155. package/lib/types/screens/Chat.d.ts.map +1 -1
  156. package/lib/types/screens/Chat.js +38 -17
  157. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  158. package/lib/types/screens/SessionBrowser.js +10 -3
  159. package/lib/types/sessions/view.d.ts +3 -2
  160. package/lib/types/sessions/view.d.ts.map +1 -1
  161. package/lib/types/sessions/view.js +18 -0
  162. package/lib/types/settings-sections.d.ts +2 -1
  163. package/lib/types/settings-sections.d.ts.map +1 -1
  164. package/lib/types/settings-sections.js +1 -1
  165. package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
  166. package/lib/types/utils/execFileNoThrow.js +3 -0
  167. package/lib/types/workspaces.d.ts +2 -1
  168. package/lib/types/workspaces.d.ts.map +1 -1
  169. package/lib/types/workspaces.js +1 -1
  170. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
  171. package/node_modules/@dsh-std/command/package.json +1 -1
  172. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  173. package/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  174. package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  175. package/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  176. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  177. package/node_modules/@dsh-std/connection/package.json +1 -1
  178. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  179. package/node_modules/@dsh-std/core/package.json +1 -1
  180. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  181. package/node_modules/@dsh-std/manifest/package.json +1 -1
  182. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
  183. package/node_modules/@dsh-std/messages/package.json +1 -1
  184. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  185. package/node_modules/@dsh-std/presentation/README.md +2 -1
  186. package/node_modules/@dsh-std/presentation/README.zh.md +2 -1
  187. package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  188. package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  189. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  190. package/node_modules/@dsh-std/presentation/lib/index.d.ts +44 -1
  191. package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -1
  192. package/node_modules/@dsh-std/presentation/lib/index.js +6 -3
  193. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  194. package/node_modules/@dsh-std/presentation/package.json +7 -3
  195. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
  196. package/node_modules/@dsh-std/storage/package.json +1 -1
  197. package/package.json +10 -5
  198. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  199. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  200. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  201. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  202. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  203. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +1 -1
  204. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  205. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +1 -1
  206. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  207. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +1 -1
  208. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  209. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +2 -1
  210. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +2 -1
  211. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  212. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  213. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  214. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +44 -1
  215. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -1
  216. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +6 -3
  217. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  218. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +7 -3
  219. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  220. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +1 -1
  221. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  222. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +1 -1
  223. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  224. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +1 -1
  225. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  226. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  227. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  228. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  229. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  230. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +1 -1
  231. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  232. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +1 -1
  233. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  234. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +1 -1
  235. package/ecosystem-spec/registry/registry-0.15.json +0 -57
  236. /package/{ecosystem-spec → dsh-ecosystem-spec}/registry/contracts/decision-events-v1alpha1.json +0 -0
  237. /package/{ecosystem-spec → dsh-ecosystem-spec}/registry/host-descriptor.tui.example.json +0 -0
  238. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/conformance-claim.schema.json +0 -0
  239. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/effect-ledger-record.schema.json +0 -0
  240. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/host-descriptor.schema.json +0 -0
@@ -0,0 +1,179 @@
1
+ import { defineCapabilityProtocol } from "@dsh-std/connection";
2
+ //#region src/callback.ts
3
+ const EXTERNAL_REDIRECT_KIND = "ExternalRedirect";
4
+ const emptySpec = (value) => {
5
+ if (value !== void 0) throw new TypeError("ExternalRedirect does not accept spec in v1alpha1");
6
+ };
7
+ const externalRedirectProtocol = defineCapabilityProtocol({
8
+ apiVersion: "presentation.dsh/v1alpha1",
9
+ kind: EXTERNAL_REDIRECT_KIND,
10
+ validateRequirement: emptySpec,
11
+ validateSupport: emptySpec
12
+ });
13
+ const externalRedirectSupport = Object.freeze({
14
+ apiVersion: "presentation.dsh/v1alpha1",
15
+ kind: EXTERNAL_REDIRECT_KIND
16
+ });
17
+ function externalRedirectClient(client, scope) {
18
+ validateScope(scope);
19
+ return Object.freeze({ receive(input = {}, options) {
20
+ const request = Object.freeze({
21
+ ...input,
22
+ mode: input.mode ?? "http-get",
23
+ requestId: nextRequestId(scope),
24
+ invocationId: scope.invocationId,
25
+ origin: scope.origin,
26
+ ...scope.deadline === void 0 ? {} : { deadline: scope.deadline }
27
+ });
28
+ validateExternalRedirectRequest(request);
29
+ const call = client.invoke(externalRedirectSupport, "receive", request, options);
30
+ return Object.freeze({
31
+ invocationId: call.invocationId,
32
+ ready: firstReady(call.progress),
33
+ result: call.result.then(validateExternalRedirectResult),
34
+ cancel: (reason) => call.cancel(reason)
35
+ });
36
+ } });
37
+ }
38
+ function externalRedirectImplementation(participantId, handler) {
39
+ return Object.freeze({
40
+ participantId,
41
+ protocol: externalRedirectSupport,
42
+ async handle(operation, input, context) {
43
+ if (operation !== "receive") throw new TypeError(`unsupported ExternalRedirect operation ${JSON.stringify(operation)}`);
44
+ validateExternalRedirectRequest(input);
45
+ let announced = false;
46
+ const guardedContext = Object.freeze({
47
+ ...context,
48
+ progress(value) {
49
+ if (announced) throw new TypeError("ExternalRedirect provider emitted more than one ready event");
50
+ validateExternalRedirectReady(value);
51
+ if (input.exactRedirectUri !== void 0 && value.redirectUri !== input.exactRedirectUri) throw new TypeError("ExternalRedirect provider did not announce the exact requested redirect URI");
52
+ announced = true;
53
+ context.progress(value);
54
+ }
55
+ });
56
+ const result = validateExternalRedirectResult(await handler.receive(input, guardedContext));
57
+ if (result.status === "submitted" && !announced) throw new TypeError("ExternalRedirect provider submitted a result before announcing redirectUri");
58
+ return result;
59
+ }
60
+ });
61
+ }
62
+ function validateExternalRedirectRequest(value) {
63
+ const request = exactRecord(value, [
64
+ "requestId",
65
+ "invocationId",
66
+ "origin",
67
+ "deadline",
68
+ "mode",
69
+ "exactRedirectUri"
70
+ ], [
71
+ "requestId",
72
+ "invocationId",
73
+ "origin",
74
+ "mode"
75
+ ], "ExternalRedirect request");
76
+ nonEmpty(request.requestId, "ExternalRedirect request.requestId");
77
+ nonEmpty(request.invocationId, "ExternalRedirect request.invocationId");
78
+ nonEmpty(request.origin, "ExternalRedirect request.origin");
79
+ if (request.mode !== "http-get") throw new TypeError("ExternalRedirect request.mode must be \"http-get\"");
80
+ if (request.exactRedirectUri !== void 0) validateLoopbackUri(request.exactRedirectUri, "ExternalRedirect request.exactRedirectUri", true);
81
+ dateTime(request.deadline, "ExternalRedirect request.deadline");
82
+ }
83
+ function validateExternalRedirectReady(value) {
84
+ const ready = exactRecord(value, [
85
+ "type",
86
+ "redirectUri",
87
+ "expiresAt"
88
+ ], ["type", "redirectUri"], "ExternalRedirect ready");
89
+ if (ready.type !== "ready") throw new TypeError("ExternalRedirect ready.type must be \"ready\"");
90
+ validateLoopbackUri(ready.redirectUri, "ExternalRedirect ready.redirectUri", false);
91
+ dateTime(ready.expiresAt, "ExternalRedirect ready.expiresAt");
92
+ }
93
+ function validateExternalRedirectResult(value) {
94
+ if (!record(value)) throw new TypeError("ExternalRedirect result must be an object");
95
+ if (value.status === "submitted") {
96
+ const submitted = exactRecord(exactRecord(value, ["status", "value"], ["status", "value"], "ExternalRedirect result").value, ["query"], ["query"], "ExternalRedirect value");
97
+ if (!record(submitted.query)) throw new TypeError("ExternalRedirect value.query must be an object");
98
+ const query = {};
99
+ for (const [name, entries] of Object.entries(submitted.query)) {
100
+ if (name === "" || !Array.isArray(entries) || entries.some((entry) => typeof entry !== "string")) throw new TypeError("ExternalRedirect value.query must map non-empty names to string arrays");
101
+ query[name] = Object.freeze([...entries]);
102
+ }
103
+ return Object.freeze({
104
+ status: "submitted",
105
+ value: Object.freeze({ query: Object.freeze(query) })
106
+ });
107
+ }
108
+ if (value.status === "unavailable") {
109
+ const result = exactRecord(value, ["status", "reason"], ["status"], "ExternalRedirect result");
110
+ if (result.reason !== void 0) nonEmpty(result.reason, "ExternalRedirect result.reason");
111
+ return Object.freeze({
112
+ status: "unavailable",
113
+ ...result.reason === void 0 ? {} : { reason: result.reason }
114
+ });
115
+ }
116
+ if (value.status === "cancelled" || value.status === "expired") {
117
+ exactRecord(value, ["status"], ["status"], "ExternalRedirect result");
118
+ return Object.freeze({ status: value.status });
119
+ }
120
+ throw new TypeError("ExternalRedirect result.status is invalid");
121
+ }
122
+ async function firstReady(progress) {
123
+ for await (const value of progress) {
124
+ validateExternalRedirectReady(value);
125
+ return Object.freeze({ ...value });
126
+ }
127
+ throw new TypeError("ExternalRedirect provider completed without announcing redirectUri");
128
+ }
129
+ function validateScope(scope) {
130
+ if (!record(scope)) throw new TypeError("Presentation invocation scope must be an object");
131
+ nonEmpty(scope.invocationId, "Presentation invocation scope.invocationId");
132
+ nonEmpty(scope.origin, "Presentation invocation scope.origin");
133
+ dateTime(scope.deadline, "Presentation invocation scope.deadline");
134
+ if (typeof scope.nextRequestId !== "function") throw new TypeError("Presentation invocation scope.nextRequestId must be a function");
135
+ }
136
+ function nextRequestId(scope) {
137
+ const value = scope.nextRequestId();
138
+ nonEmpty(value, "Presentation requestId");
139
+ return value;
140
+ }
141
+ function exactRecord(value, allowed, required, label) {
142
+ if (!record(value)) throw new TypeError(`${label} must be an object`);
143
+ const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
144
+ if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`);
145
+ for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`);
146
+ return value;
147
+ }
148
+ function record(value) {
149
+ return typeof value === "object" && value !== null && !Array.isArray(value);
150
+ }
151
+ function nonEmpty(value, label) {
152
+ if (typeof value !== "string" || value.trim() === "") throw new TypeError(`${label} must be a non-empty string`);
153
+ }
154
+ function dateTime(value, label) {
155
+ if (value !== void 0 && (typeof value !== "string" || Number.isNaN(Date.parse(value)))) throw new TypeError(`${label} must be an RFC 3339 date-time`);
156
+ }
157
+ function validateLoopbackUri(value, label, requireExplicitPort) {
158
+ nonEmpty(value, label);
159
+ let uri;
160
+ try {
161
+ uri = new URL(value);
162
+ } catch {
163
+ throw new TypeError(`${label} must be an absolute URI`);
164
+ }
165
+ if (uri.protocol !== "http:") throw new TypeError(`${label} must use HTTP`);
166
+ if (uri.hostname !== "127.0.0.1" && uri.hostname !== "[::1]" && uri.hostname !== "localhost") throw new TypeError(`${label} must target a loopback host`);
167
+ if (uri.username !== "" || uri.password !== "") throw new TypeError(`${label} must not contain user information`);
168
+ if (uri.hash !== "") throw new TypeError(`${label} must not contain a fragment`);
169
+ if (requireExplicitPort) {
170
+ const authority = value.slice(value.indexOf("//") + 2).split(/[/?#]/u, 1)[0];
171
+ const match = /^(?:127\.0\.0\.1|localhost):(\d+)$|^\[::1\]:(\d+)$/iu.exec(authority);
172
+ const port = Number(match?.[1] ?? match?.[2]);
173
+ if (!Number.isSafeInteger(port) || port < 1 || port > 65535) throw new TypeError(`${label} must include an explicit TCP port`);
174
+ }
175
+ }
176
+ //#endregion
177
+ export { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult };
178
+
179
+ //# sourceMappingURL=callback.js.map
@@ -0,0 +1 @@
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,MAAM,UAAU,OAAO,OAAO;GAC5B,GAAG;GACH,MAAM,MAAM,QAAQ;GACpB,WAAW,cAAc,KAAK;GAAG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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"}
@@ -173,6 +173,7 @@ interface PresentationClients {
173
173
  readonly copyText?: CopyTextClient;
174
174
  readonly notification?: NotificationClient;
175
175
  readonly interaction?: UserInteractionClient;
176
+ readonly externalRedirect?: ExternalRedirectClient;
176
177
  }
177
178
  interface OpenExternalHandler {
178
179
  openExternal(request: OpenExternalRequest, context: CapabilityHandlerContext): PresentationResult<OpenExternalReceipt> | Promise<PresentationResult<OpenExternalReceipt>>;
@@ -215,5 +216,47 @@ declare function validateUserInteractionRequest(value: unknown): asserts value i
215
216
  declare function validateUserInteractionRequirement(value: unknown): UserInteractionRequirementSpec;
216
217
  declare function validateUserInteractionSupport(value: unknown): UserInteractionSupportSpec;
217
218
  //#endregion
218
- export { API_VERSION, ApprovalDetail, ApprovalInput, ApprovalRequest, ApprovalValue, COPY_TEXT_KIND, ConfirmQuestionField, CopyTextClient, CopyTextHandler, CopyTextInput, CopyTextReceipt, CopyTextRequest, NOTIFICATION_KIND, NotificationClient, NotificationHandler, NotificationInput, NotificationReceipt, NotificationRequest, OPEN_EXTERNAL_KIND, OpenExternalClient, OpenExternalHandler, OpenExternalInput, OpenExternalReceipt, OpenExternalRequest, PresentationClients, PresentationDescriptor, PresentationInvocationScope, PresentationRequestContext, PresentationResult, QuestionAnswers, QuestionField, QuestionInput, QuestionOption, QuestionRequest, SecretInput, SecretInputRequest, SecretInputValue, SelectQuestionField, TextQuestionField, USER_INTERACTION_KIND, UserInteractionClient, UserInteractionHandler, UserInteractionLimits, UserInteractionOperation, UserInteractionRequest, UserInteractionRequirementSpec, UserInteractionSupportSpec, UserInteractionValue, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport };
219
+ //#region src/callback.d.ts
220
+ declare const EXTERNAL_REDIRECT_KIND = "ExternalRedirect";
221
+ interface ExternalRedirectRequest extends PresentationRequestContext {
222
+ readonly mode: 'http-get';
223
+ /** Exact loopback URI required by the external provider, including an explicit port. */
224
+ readonly exactRedirectUri?: string;
225
+ }
226
+ interface ExternalRedirectInput {
227
+ readonly mode?: 'http-get';
228
+ /** The provider must bind and announce this exact URI or report the request unavailable. */
229
+ readonly exactRedirectUri?: string;
230
+ }
231
+ interface ExternalRedirectReady {
232
+ readonly type: 'ready';
233
+ readonly redirectUri: string;
234
+ readonly expiresAt?: string;
235
+ }
236
+ interface ExternalRedirectValue {
237
+ readonly query: Readonly<Record<string, readonly string[]>>;
238
+ }
239
+ interface ExternalRedirectCall {
240
+ readonly invocationId: string;
241
+ readonly ready: Promise<ExternalRedirectReady>;
242
+ readonly result: Promise<PresentationResult<ExternalRedirectValue>>;
243
+ cancel(reason?: string): void;
244
+ }
245
+ interface ExternalRedirectClient {
246
+ receive(input?: ExternalRedirectInput, options?: {
247
+ readonly signal?: AbortSignal;
248
+ }): ExternalRedirectCall;
249
+ }
250
+ interface ExternalRedirectHandler {
251
+ receive(request: ExternalRedirectRequest, context: CapabilityHandlerContext<ExternalRedirectReady>): PresentationResult<ExternalRedirectValue> | Promise<PresentationResult<ExternalRedirectValue>>;
252
+ }
253
+ declare const externalRedirectProtocol: import("@dsh-std/core").ProtocolDefinition<unknown, unknown, unknown, unknown>;
254
+ declare const externalRedirectSupport: ProtocolSupport;
255
+ declare function externalRedirectClient(client: CapabilityClient, scope: PresentationInvocationScope): ExternalRedirectClient;
256
+ declare function externalRedirectImplementation(participantId: string, handler: ExternalRedirectHandler): CapabilityImplementation<ExternalRedirectRequest, PresentationResult<ExternalRedirectValue>, ExternalRedirectReady>;
257
+ declare function validateExternalRedirectRequest(value: unknown): asserts value is ExternalRedirectRequest;
258
+ declare function validateExternalRedirectReady(value: unknown): asserts value is ExternalRedirectReady;
259
+ declare function validateExternalRedirectResult(value: unknown): PresentationResult<ExternalRedirectValue>;
260
+ //#endregion
261
+ export { API_VERSION, ApprovalDetail, ApprovalInput, ApprovalRequest, ApprovalValue, COPY_TEXT_KIND, ConfirmQuestionField, CopyTextClient, CopyTextHandler, CopyTextInput, CopyTextReceipt, CopyTextRequest, EXTERNAL_REDIRECT_KIND, ExternalRedirectCall, ExternalRedirectClient, ExternalRedirectHandler, ExternalRedirectInput, ExternalRedirectReady, ExternalRedirectRequest, ExternalRedirectValue, NOTIFICATION_KIND, NotificationClient, NotificationHandler, NotificationInput, NotificationReceipt, NotificationRequest, OPEN_EXTERNAL_KIND, OpenExternalClient, OpenExternalHandler, OpenExternalInput, OpenExternalReceipt, OpenExternalRequest, PresentationClients, PresentationDescriptor, PresentationInvocationScope, PresentationRequestContext, PresentationResult, QuestionAnswers, QuestionField, QuestionInput, QuestionOption, QuestionRequest, SecretInput, SecretInputRequest, SecretInputValue, SelectQuestionField, TextQuestionField, USER_INTERACTION_KIND, UserInteractionClient, UserInteractionHandler, UserInteractionLimits, UserInteractionOperation, UserInteractionRequest, UserInteractionRequirementSpec, UserInteractionSupportSpec, UserInteractionValue, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport };
219
262
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAgBa;cACA;cACA;cACA;cACA;UAEI;;WAEN;;WAEA,oBAAoB;;UAGd;WACN;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;EACT;;KAGU,mBAAmB;WAChB;WAA8B,OAAO;;WACrC;;WACA;;WACA;WAAgC;;UAE9B,4BAA4B;WAClC;;KAGC,oBAAoB,KAAK,2BAA2B;UAE/C;WAA+B;;UAE/B,wBAAwB;WAC9B;WACA;;KAGC,gBAAgB,KAAK,uBAAuB;UAEvC;WAA2B;;UAE3B,4BAA4B;WAClC;WACA;WACA;;KAGC,oBAAoB,KAAK,2BAA2B;UAE/C;WAA+B;;KAEpC;UAEK;WACN,qBAAqB;WACrB,8BAA8B;;UAGxB;WACN;WACA;WACA;WACA;;UAGM;WACN,qBAAqB;WACrB,SAAS;;UAGH;WACN;WACA;WACA;;UAGD;WACC;WACA;WACA;WACA;;UAGM,0BAA0B;WAChC;WACA;WACA;WACA;;UAGM,4BAA4B;WAClC;WACA;WACA,kBAAkB;;UAGZ,6BAA6B;WACnC;;KAGC,gBAAgB,oBAAoB,sBAAsB;UAErD,wBAAwB;WAC9B;WACA;WACA;WACA,iBAAiB;;UAGX;WACN,SAAS,SAAS;;UAGZ;WACN;WACA;WACA;;UAGM,wBAAwB;WAC9B;WACA;WACA;WACA,mBAAmB;WACnB;;UAGM;WAAyB;;UAEzB,2BAA2B;WACjC;WACA;WACA;WACA;WACA;;UAGM;WAA4B;;KAEjC,yBAAyB,kBAAkB,kBAAkB;KAC7D,uBAAuB,kBAAkB,gBAAgB;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AkB,OAAO,8BAA8B;iBAclF,eAAe,QAAQ,kBAAkB,OAAO,8BAA8B;iBAc9E,mBAAmB,QAAQ,kBAAkB,OAAO,8BAA8B;iBAclF,sBAAsB,QAAQ,kBAAkB,OAAO,8BAA8B;iBAcrF,oBACd,YAAY,wBACZ,QAAQ,kBACR,OAAO,8BACN;iBAca,2BAA2B,uBAAuB,SAAS,sBAAsB;iBAKjF,uBAAuB,uBAAuB,SAAS,kBAAkB;iBAKzE,2BAA2B,uBAAuB,SAAS,sBAAsB;iBAKjF,8BACd,uBACA,MAAM,4BACN,SAAS,yBACR;iBAea,+BAA+B,yBAAyB,SAAS;iBAejE,4BAA4B,yBAAyB,SAAS;iBAO9D,wBAAwB,yBAAyB,SAAS;iBAQ1D,4BAA4B,yBAAyB,SAAS;iBAS9D,+BAA+B,yBAAyB,SAAS;iBAQjE,mCAAmC,iBAAiB;iBAYpD,+BAA+B,iBAAiB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts","../src/callback.ts"],"mappings":";;;cAoBa;cACA;cACA;cACA;cACA;UAEI;;WAEN;;WAEA,oBAAoB;;UAGd;WACN;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;EACT;;KAGU,mBAAmB;WAChB;WAA8B,OAAO;;WACrC;;WACA;;WACA;WAAgC;;UAE9B,4BAA4B;WAClC;;KAGC,oBAAoB,KAAK,2BAA2B;UAE/C;WAA+B;;UAE/B,wBAAwB;WAC9B;WACA;;KAGC,gBAAgB,KAAK,uBAAuB;UAEvC;WAA2B;;UAE3B,4BAA4B;WAClC;WACA;WACA;;KAGC,oBAAoB,KAAK,2BAA2B;UAE/C;WAA+B;;KAEpC;UAEK;WACN,qBAAqB;WACrB,8BAA8B;;UAGxB;WACN;WACA;WACA;WACA;;UAGM;WACN,qBAAqB;WACrB,SAAS;;UAGH;WACN;WACA;WACA;;UAGD;WACC;WACA;WACA;WACA;;UAGM,0BAA0B;WAChC;WACA;WACA;WACA;;UAGM,4BAA4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BAAmB,yBAAyB,QAAQ,mBAAmB;;cAQ/D,kDAAwB;cAIxB,yBAAyB;iBAItB,uBAAuB,QAAQ,kBAAkB,OAAO,8BAA8B;iBAwBtF,+BACd,uBACA,SAAS,0BACR,yBAAyB,yBAAyB,mBAAmB,wBAAwB;iBA4BhF,gCAAgC,yBAAyB,SAAS;iBAUlE,8BAA8B,yBAAyB,SAAS;iBAOhE,+BAA+B,iBAAiB,mBAAmB"}
@@ -1,3 +1,4 @@
1
+ import { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult } from "./callback.js";
1
2
  import { defineCapabilityProtocol } from "@dsh-std/connection";
2
3
  //#region src/index.ts
3
4
  const API_VERSION = "presentation.dsh/v1alpha1";
@@ -54,7 +55,8 @@ const protocols = Object.freeze([
54
55
  openExternalProtocol,
55
56
  copyTextProtocol,
56
57
  notificationProtocol,
57
- userInteractionProtocol
58
+ userInteractionProtocol,
59
+ externalRedirectProtocol
58
60
  ]);
59
61
  function register(catalog) {
60
62
  const disposers = protocols.map((protocol) => catalog.register(protocol));
@@ -106,7 +108,8 @@ function presentationClients(descriptor, client, scope) {
106
108
  ...has("OpenExternal") ? { openExternal: openExternalClient(client, scope) } : {},
107
109
  ...has("CopyText") ? { copyText: copyTextClient(client, scope) } : {},
108
110
  ...has("Notification") ? { notification: notificationClient(client, scope) } : {},
109
- ...has("UserInteraction") ? { interaction: userInteractionClient(client, scope) } : {}
111
+ ...has("UserInteraction") ? { interaction: userInteractionClient(client, scope) } : {},
112
+ ...has("ExternalRedirect") ? { externalRedirect: externalRedirectClient(client, scope) } : {}
110
113
  });
111
114
  }
112
115
  function openExternalImplementation(participantId, handler) {
@@ -542,6 +545,6 @@ function deepFreeze(value) {
542
545
  return value;
543
546
  }
544
547
  //#endregion
545
- export { API_VERSION, COPY_TEXT_KIND, NOTIFICATION_KIND, OPEN_EXTERNAL_KIND, USER_INTERACTION_KIND, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport };
548
+ export { API_VERSION, COPY_TEXT_KIND, EXTERNAL_REDIRECT_KIND, NOTIFICATION_KIND, OPEN_EXTERNAL_KIND, USER_INTERACTION_KIND, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport };
546
549
 
547
550
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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'\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}\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])\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 })\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":";;AAgBA,MAAa,cAAc;AAC3B,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,wBAAwB;AAoMrC,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,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Q,OAAgB,OAAwC;CACvE,IAAI,OAAO,UAAU,YAAY,CAAC,6BAA6B,KAAK,KAAK,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,YAAY;AACvH;AAEA,SAAS,gBAAgB,OAAgB,OAAqB;CAC5D,IAAI,CAAC,OAAO,cAAc,KAAK,KAAM,QAAmB,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,iCAAiC;AAC3H;AAEA,SAAS,mBAAmB,OAAgB,OAAqB;CAC/D,IAAI,CAAC,OAAO,cAAc,KAAK,KAAM,QAAmB,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,qCAAqC;AAC/H;AAEA,SAAS,YAAe,OAAa;CAAE,OAAO,WAAW,gBAAgB,KAAK,CAAC;AAAE;AAEjF,SAAS,WAAc,OAAa;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
+ {"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,qB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