@deepseek-harness-tui/dsh-tui 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +4 -4
  2. package/bin/dsh-tui.js +26 -4
  3. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
  4. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
  5. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
  6. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
  7. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
  8. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
  9. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
  10. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
  11. package/dsh-ecosystem-spec/registry/README.md +14 -14
  12. package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
  13. package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
  14. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
  15. package/lib/types/commands.d.ts.map +1 -1
  16. package/lib/types/commands.js +7 -8
  17. package/lib/types/components/BalanceReportRow.d.ts +24 -0
  18. package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
  19. package/lib/types/components/BalanceReportRow.js +87 -0
  20. package/lib/types/components/HistorySearchDialog.js +1 -1
  21. package/lib/types/components/MessageList.d.ts +3 -1
  22. package/lib/types/components/MessageList.d.ts.map +1 -1
  23. package/lib/types/components/MessageList.js +11 -7
  24. package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
  25. package/lib/types/components/PluginSceneBoundary.js +1 -1
  26. package/lib/types/components/PromptInput.d.ts.map +1 -1
  27. package/lib/types/components/PromptInput.js +16 -0
  28. package/lib/types/components/Whale.d.ts +15 -4
  29. package/lib/types/components/Whale.d.ts.map +1 -1
  30. package/lib/types/components/Whale.js +9 -8
  31. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
  32. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  33. package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
  34. package/lib/types/deepseekBalance.d.ts +53 -0
  35. package/lib/types/deepseekBalance.d.ts.map +1 -0
  36. package/lib/types/deepseekBalance.js +86 -0
  37. package/lib/types/deepseekPricing.d.ts +82 -0
  38. package/lib/types/deepseekPricing.d.ts.map +1 -0
  39. package/lib/types/deepseekPricing.js +133 -0
  40. package/lib/types/dsh-adapter/channel.d.ts +46 -1
  41. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  42. package/lib/types/dsh-adapter/channel.js +84 -10
  43. package/lib/types/dsh-adapter/index.d.ts +5 -0
  44. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  45. package/lib/types/dsh-adapter/index.js +1 -0
  46. package/lib/types/dsh-adapter/packaged-skills.d.ts +9 -0
  47. package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/packaged-skills.js +19 -4
  49. package/lib/types/dsh-adapter/plugin.d.ts +6 -0
  50. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  51. package/lib/types/dsh-adapter/plugin.js +122 -18
  52. package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
  53. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  54. package/lib/types/dsh-adapter/settings-sections.js +35 -2
  55. package/lib/types/history.d.ts +4 -3
  56. package/lib/types/history.d.ts.map +1 -1
  57. package/lib/types/history.js +66 -18
  58. package/lib/types/i18n.d.ts +122 -55
  59. package/lib/types/i18n.d.ts.map +1 -1
  60. package/lib/types/i18n.js +39 -18
  61. package/lib/types/ink/ink.d.ts.map +1 -1
  62. package/lib/types/ink/ink.js +67 -17
  63. package/lib/types/ink/root.d.ts +16 -0
  64. package/lib/types/ink/root.d.ts.map +1 -1
  65. package/lib/types/ink/root.js +2 -0
  66. package/lib/types/ink/terminal-querier.d.ts +8 -0
  67. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  68. package/lib/types/ink/terminal-querier.js +13 -0
  69. package/lib/types/ink/terminal.d.ts +42 -0
  70. package/lib/types/ink/terminal.d.ts.map +1 -1
  71. package/lib/types/ink/terminal.js +52 -2
  72. package/lib/types/plugin-spec/registry.d.ts +1 -1
  73. package/lib/types/plugin-spec/registry.js +1 -1
  74. package/lib/types/screens/Chat.d.ts.map +1 -1
  75. package/lib/types/screens/Chat.js +72 -37
  76. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  77. package/lib/types/screens/SessionBrowser.js +28 -13
  78. package/lib/types/screens/SessionTree.d.ts.map +1 -1
  79. package/lib/types/screens/SessionTree.js +33 -9
  80. package/lib/types/screens/Settings.d.ts +7 -5
  81. package/lib/types/screens/Settings.d.ts.map +1 -1
  82. package/lib/types/screens/Settings.js +206 -99
  83. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  84. package/lib/types/screens/StatusLine.js +32 -1
  85. package/lib/types/sessionHistory.d.ts +11 -0
  86. package/lib/types/sessionHistory.d.ts.map +1 -1
  87. package/lib/types/sessionHistory.js +29 -0
  88. package/lib/types/sessions/format.d.ts.map +1 -1
  89. package/lib/types/sessions/format.js +14 -4
  90. package/lib/types/tips.js +2 -2
  91. package/lib/types/tuiDisplayPrefs.d.ts +3 -0
  92. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  93. package/lib/types/tuiDisplayPrefs.js +1 -0
  94. package/lib/types/update.d.ts +46 -0
  95. package/lib/types/update.d.ts.map +1 -1
  96. package/lib/types/update.js +232 -3
  97. package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
  98. package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
  99. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
  100. package/node_modules/@dsh-std/command/LICENSE +21 -21
  101. package/node_modules/@dsh-std/command/README.md +26 -26
  102. package/node_modules/@dsh-std/command/README.zh.md +28 -28
  103. package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
  104. package/node_modules/@dsh-std/command/package.json +22 -22
  105. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  106. package/node_modules/@dsh-std/connection/LICENSE +21 -21
  107. package/node_modules/@dsh-std/connection/README.md +42 -42
  108. package/node_modules/@dsh-std/connection/README.zh.md +42 -42
  109. package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  110. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  111. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  112. package/node_modules/@dsh-std/connection/package.json +20 -20
  113. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  114. package/node_modules/@dsh-std/core/LICENSE +21 -21
  115. package/node_modules/@dsh-std/core/README.md +13 -13
  116. package/node_modules/@dsh-std/core/README.zh.md +13 -13
  117. package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  118. package/node_modules/@dsh-std/core/package.json +21 -21
  119. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  120. package/node_modules/@dsh-std/manifest/LICENSE +21 -21
  121. package/node_modules/@dsh-std/manifest/README.md +5 -5
  122. package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  123. package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  124. package/node_modules/@dsh-std/manifest/package.json +20 -20
  125. package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  126. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
  127. package/node_modules/@dsh-std/messages/LICENSE +21 -21
  128. package/node_modules/@dsh-std/messages/README.md +5 -5
  129. package/node_modules/@dsh-std/messages/README.zh.md +7 -7
  130. package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
  131. package/node_modules/@dsh-std/messages/package.json +20 -20
  132. package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
  133. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  134. package/node_modules/@dsh-std/presentation/LICENSE +21 -21
  135. package/node_modules/@dsh-std/presentation/README.md +27 -27
  136. package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  137. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  138. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  139. package/node_modules/@dsh-std/presentation/package.json +25 -25
  140. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
  141. package/node_modules/@dsh-std/storage/LICENSE +21 -21
  142. package/node_modules/@dsh-std/storage/README.md +5 -5
  143. package/node_modules/@dsh-std/storage/README.zh.md +7 -7
  144. package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
  145. package/node_modules/@dsh-std/storage/package.json +20 -20
  146. package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
  147. package/package.json +95 -5
  148. package/skills/pr-comments/SKILL.md +1 -1
  149. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  150. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
  151. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
  152. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
  153. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  154. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  155. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  156. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
  157. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  158. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
  159. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
  160. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
  161. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  162. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
  163. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  164. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
  165. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
  166. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  167. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  168. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
  169. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  170. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  171. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
  172. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
  173. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  174. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  175. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  176. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
  177. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  178. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
  179. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
  180. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
  181. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  182. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
  183. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  184. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
  185. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
  186. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
  187. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  188. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
  189. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  190. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
  191. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
  192. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
  193. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  194. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
  195. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  196. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
  197. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
  198. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
  199. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  200. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  201. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  202. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
  203. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  204. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
  205. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
  206. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
  207. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  208. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
  209. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  210. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
  211. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
  212. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
  213. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  214. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -21
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\r\n ProtocolCatalog,\r\n ProtocolDefinition,\r\n ProtocolIssue,\r\n ProtocolNegotiationInput,\r\n ProtocolRequirement,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\nimport type {\r\n CapabilityClient,\r\n CapabilityHandlerContext,\r\n CapabilityImplementation,\r\n ConnectionNegotiationPolicy,\r\n} from '@dsh-std/connection'\r\nimport { defineCapabilityProtocol } from '@dsh-std/connection'\r\nimport { EXTERNAL_REDIRECT_KIND, externalRedirectClient, externalRedirectProtocol } from './callback.js'\r\nimport type { ExternalRedirectClient } from './callback.js'\r\n\r\nexport * from './callback.js'\r\n\r\nexport const API_VERSION = 'presentation.dsh/v1alpha1'\r\nexport const OPEN_EXTERNAL_KIND = 'OpenExternal'\r\nexport const COPY_TEXT_KIND = 'CopyText'\r\nexport const NOTIFICATION_KIND = 'Notification'\r\nexport const USER_INTERACTION_KIND = 'UserInteraction'\r\n\r\nexport interface PresentationDescriptor {\r\n /** Endpoint identity selected and authenticated by the Host for this invocation. */\r\n readonly clientId: string\r\n /** Active Presentation agreements projected into this invocation. */\r\n readonly contracts: readonly ProtocolSupport[]\r\n}\r\n\r\nexport interface PresentationRequestContext {\r\n readonly requestId: string\r\n readonly invocationId: string\r\n readonly origin: string\r\n readonly deadline?: string\r\n}\r\n\r\n/** Invocation authority supplied by the Host when it creates scoped clients. */\r\nexport interface PresentationInvocationScope {\r\n readonly invocationId: string\r\n readonly origin: string\r\n readonly deadline?: string\r\n nextRequestId(): string\r\n}\r\n\r\nexport type PresentationResult<T> =\r\n | { readonly status: 'submitted'; readonly value: T }\r\n | { readonly status: 'cancelled' }\r\n | { readonly status: 'expired' }\r\n | { readonly status: 'unavailable'; readonly reason?: string }\r\n\r\nexport interface OpenExternalRequest extends PresentationRequestContext {\r\n readonly uri: string\r\n}\r\n\r\nexport type OpenExternalInput = Omit<OpenExternalRequest, keyof PresentationRequestContext>\r\n\r\nexport interface OpenExternalReceipt { readonly accepted: true }\r\n\r\nexport interface CopyTextRequest extends PresentationRequestContext {\r\n readonly text: string\r\n readonly sensitivity?: 'public' | 'private'\r\n}\r\n\r\nexport type CopyTextInput = Omit<CopyTextRequest, keyof PresentationRequestContext>\r\n\r\nexport interface CopyTextReceipt { readonly accepted: true }\r\n\r\nexport interface NotificationRequest extends PresentationRequestContext {\r\n readonly text: string\r\n readonly level?: 'info' | 'warning' | 'error'\r\n readonly deduplicationKey?: string\r\n}\r\n\r\nexport type NotificationInput = Omit<NotificationRequest, keyof PresentationRequestContext>\r\n\r\nexport interface NotificationReceipt { readonly accepted: true }\r\n\r\nexport type UserInteractionOperation = 'question' | 'approval' | 'secret-input'\r\n\r\nexport interface UserInteractionRequirementSpec {\r\n readonly operations: readonly UserInteractionOperation[]\r\n readonly optionalOperations?: readonly UserInteractionOperation[]\r\n}\r\n\r\nexport interface UserInteractionLimits {\r\n readonly maxConcurrentRequests?: number\r\n readonly maxFields?: number\r\n readonly maxOptionsPerField?: number\r\n readonly maxTextLength?: number\r\n}\r\n\r\nexport interface UserInteractionSupportSpec {\r\n readonly operations: readonly UserInteractionOperation[]\r\n readonly limits?: UserInteractionLimits\r\n}\r\n\r\nexport interface QuestionOption {\r\n readonly id: string\r\n readonly label: string\r\n readonly description?: string\r\n}\r\n\r\ninterface QuestionFieldBase {\r\n readonly id: string\r\n readonly label: string\r\n readonly description?: string\r\n readonly required?: boolean\r\n}\r\n\r\nexport interface TextQuestionField extends QuestionFieldBase {\r\n readonly kind: 'text'\r\n readonly multiline?: boolean\r\n readonly minLength?: number\r\n readonly maxLength?: number\r\n}\r\n\r\nexport interface SelectQuestionField extends QuestionFieldBase {\r\n readonly kind: 'select'\r\n readonly multiple?: boolean\r\n readonly options: readonly QuestionOption[]\r\n}\r\n\r\nexport interface ConfirmQuestionField extends QuestionFieldBase {\r\n readonly kind: 'confirm'\r\n}\r\n\r\nexport type QuestionField = TextQuestionField | SelectQuestionField | ConfirmQuestionField\r\n\r\nexport interface QuestionRequest extends PresentationRequestContext {\r\n readonly kind: 'question'\r\n readonly title?: string\r\n readonly description?: string\r\n readonly fields: readonly QuestionField[]\r\n}\r\n\r\nexport interface QuestionAnswers {\r\n readonly answers: Readonly<Record<string, string | boolean | readonly string[]>>\r\n}\r\n\r\nexport interface ApprovalDetail {\r\n readonly label: string\r\n readonly value: string\r\n readonly sensitivity?: 'public' | 'private'\r\n}\r\n\r\nexport interface ApprovalRequest extends PresentationRequestContext {\r\n readonly kind: 'approval'\r\n readonly action: string\r\n readonly summary: string\r\n readonly details?: readonly ApprovalDetail[]\r\n readonly risk?: 'low' | 'medium' | 'high'\r\n}\r\n\r\nexport interface ApprovalValue { readonly decision: 'approved' | 'denied' }\r\n\r\nexport interface SecretInputRequest extends PresentationRequestContext {\r\n readonly kind: 'secret-input'\r\n readonly label: string\r\n readonly description?: string\r\n readonly minLength?: number\r\n readonly maxLength?: number\r\n}\r\n\r\nexport interface SecretInputValue { readonly secret: string }\r\n\r\nexport type UserInteractionRequest = QuestionRequest | ApprovalRequest | SecretInputRequest\r\nexport type UserInteractionValue = QuestionAnswers | ApprovalValue | SecretInputValue\r\nexport type QuestionInput = Omit<QuestionRequest, keyof PresentationRequestContext>\r\nexport type ApprovalInput = Omit<ApprovalRequest, keyof PresentationRequestContext>\r\nexport type SecretInput = Omit<SecretInputRequest, keyof PresentationRequestContext>\r\n\r\nexport interface OpenExternalClient {\r\n openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<OpenExternalReceipt>>\r\n}\r\n\r\nexport interface CopyTextClient {\r\n copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<CopyTextReceipt>>\r\n}\r\n\r\nexport interface NotificationClient {\r\n notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<NotificationReceipt>>\r\n}\r\n\r\nexport interface UserInteractionClient {\r\n interact(input: QuestionInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<QuestionAnswers>>\r\n interact(input: ApprovalInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<ApprovalValue>>\r\n interact(input: SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<SecretInputValue>>\r\n}\r\n\r\n/** Typed Presentation capabilities available to one domain invocation. */\r\nexport interface PresentationClients {\r\n readonly descriptor: PresentationDescriptor\r\n readonly openExternal?: OpenExternalClient\r\n readonly copyText?: CopyTextClient\r\n readonly notification?: NotificationClient\r\n readonly interaction?: UserInteractionClient\r\n readonly externalRedirect?: ExternalRedirectClient\r\n}\r\n\r\nexport interface OpenExternalHandler {\r\n openExternal(request: OpenExternalRequest, context: CapabilityHandlerContext): PresentationResult<OpenExternalReceipt> | Promise<PresentationResult<OpenExternalReceipt>>\r\n}\r\n\r\nexport interface CopyTextHandler {\r\n copyText(request: CopyTextRequest, context: CapabilityHandlerContext): PresentationResult<CopyTextReceipt> | Promise<PresentationResult<CopyTextReceipt>>\r\n}\r\n\r\nexport interface NotificationHandler {\r\n notify(request: NotificationRequest, context: CapabilityHandlerContext): PresentationResult<NotificationReceipt> | Promise<PresentationResult<NotificationReceipt>>\r\n}\r\n\r\nexport interface UserInteractionHandler {\r\n interact(request: QuestionRequest, context: CapabilityHandlerContext): PresentationResult<QuestionAnswers> | Promise<PresentationResult<QuestionAnswers>>\r\n interact(request: ApprovalRequest, context: CapabilityHandlerContext): PresentationResult<ApprovalValue> | Promise<PresentationResult<ApprovalValue>>\r\n interact(request: SecretInputRequest, context: CapabilityHandlerContext): PresentationResult<SecretInputValue> | Promise<PresentationResult<SecretInputValue>>\r\n}\r\n\r\nconst emptySpec = (value: unknown): undefined => {\r\n if (value !== undefined) throw new TypeError('Presentation operation does not accept spec in v1alpha1')\r\n return undefined\r\n}\r\n\r\nexport const openExternalProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\nexport const copyTextProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: COPY_TEXT_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\nexport const notificationProtocol = defineCapabilityProtocol({\r\n apiVersion: API_VERSION, kind: NOTIFICATION_KIND, validateRequirement: emptySpec, validateSupport: emptySpec,\r\n})\r\n\r\nexport const openExternalSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: OPEN_EXTERNAL_KIND })\r\nexport const copyTextSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: COPY_TEXT_KIND })\r\nexport const notificationSupport: ProtocolSupport = Object.freeze({ apiVersion: API_VERSION, kind: NOTIFICATION_KIND })\r\nexport const userInteractionSupport = (spec: UserInteractionSupportSpec): ProtocolSupport<UserInteractionSupportSpec> =>\r\n Object.freeze({ apiVersion: API_VERSION, kind: USER_INTERACTION_KIND, spec: validateUserInteractionSupport(spec) })\r\n\r\nexport const userInteractionProtocol: ProtocolDefinition<\r\n UserInteractionRequirementSpec,\r\n UserInteractionSupportSpec\r\n> = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: USER_INTERACTION_KIND,\r\n validateRequirement: validateUserInteractionRequirement,\r\n validateSupport: validateUserInteractionSupport,\r\n negotiate: negotiateUserInteraction,\r\n})\r\n\r\nexport const protocols: readonly ProtocolDefinition[] = Object.freeze([\r\n openExternalProtocol,\r\n copyTextProtocol,\r\n notificationProtocol,\r\n userInteractionProtocol,\r\n externalRedirectProtocol,\r\n])\r\n\r\nexport function register(catalog: ProtocolCatalog): () => void {\r\n const disposers = protocols.map(protocol => catalog.register(protocol))\r\n return () => { for (const dispose of disposers.reverse()) dispose() }\r\n}\r\n\r\nexport function openExternalClient(client: CapabilityClient, scope: PresentationInvocationScope): OpenExternalClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateOpenExternalRequest(value)\r\n const result = await client.invoke<OpenExternalRequest, PresentationResult<OpenExternalReceipt>>(\r\n openExternalSupport, 'openExternal', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result')\r\n },\r\n })\r\n}\r\n\r\nexport function copyTextClient(client: CapabilityClient, scope: PresentationInvocationScope): CopyTextClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateCopyTextRequest(value)\r\n const result = await client.invoke<CopyTextRequest, PresentationResult<CopyTextReceipt>>(\r\n copyTextSupport, 'copyText', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result')\r\n },\r\n })\r\n}\r\n\r\nexport function notificationClient(client: CapabilityClient, scope: PresentationInvocationScope): NotificationClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async notify(input: NotificationInput, options?: { readonly signal?: AbortSignal }) {\r\n const value = request(input)\r\n validateNotificationRequest(value)\r\n const result = await client.invoke<NotificationRequest, PresentationResult<NotificationReceipt>>(\r\n notificationSupport, 'notify', value, options,\r\n ).result\r\n return validatePresentationResult(result, validateAcceptedReceipt, 'Notification result')\r\n },\r\n })\r\n}\r\n\r\nexport function userInteractionClient(client: CapabilityClient, scope: PresentationInvocationScope): UserInteractionClient {\r\n const request = requestFactory(scope)\r\n return Object.freeze({\r\n async interact(input: QuestionInput | ApprovalInput | SecretInput, options?: { readonly signal?: AbortSignal }): Promise<PresentationResult<UserInteractionValue>> {\r\n const value = request(input) as UserInteractionRequest\r\n validateUserInteractionRequest(value)\r\n const result = await client.invoke<UserInteractionRequest, PresentationResult<UserInteractionValue>>(\r\n { apiVersion: API_VERSION, kind: USER_INTERACTION_KIND }, 'interact', value, options,\r\n ).result\r\n return validateInteractionResult(value, result)\r\n },\r\n }) as UserInteractionClient\r\n}\r\n\r\nexport function presentationClients(\r\n descriptor: PresentationDescriptor,\r\n client: CapabilityClient,\r\n scope: PresentationInvocationScope,\r\n): PresentationClients {\r\n validatePresentationDescriptor(descriptor)\r\n validateInvocationScope(scope)\r\n const has = (kind: string) => descriptor.contracts.some(contract =>\r\n contract.apiVersion === API_VERSION && contract.kind === kind && client.binding(contract) !== undefined)\r\n return Object.freeze({\r\n descriptor: freezeClone(descriptor),\r\n ...(has(OPEN_EXTERNAL_KIND) ? { openExternal: openExternalClient(client, scope) } : {}),\r\n ...(has(COPY_TEXT_KIND) ? { copyText: copyTextClient(client, scope) } : {}),\r\n ...(has(NOTIFICATION_KIND) ? { notification: notificationClient(client, scope) } : {}),\r\n ...(has(USER_INTERACTION_KIND) ? { interaction: userInteractionClient(client, scope) } : {}),\r\n ...(has(EXTERNAL_REDIRECT_KIND) ? { externalRedirect: externalRedirectClient(client, scope) } : {}),\r\n })\r\n}\r\n\r\nexport function openExternalImplementation(participantId: string, handler: OpenExternalHandler): CapabilityImplementation {\r\n return implementation(participantId, openExternalSupport, 'openExternal', validateOpenExternalRequest, handler.openExternal.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'OpenExternal result'))\r\n}\r\n\r\nexport function copyTextImplementation(participantId: string, handler: CopyTextHandler): CapabilityImplementation {\r\n return implementation(participantId, copyTextSupport, 'copyText', validateCopyTextRequest, handler.copyText.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'CopyText result'))\r\n}\r\n\r\nexport function notificationImplementation(participantId: string, handler: NotificationHandler): CapabilityImplementation {\r\n return implementation(participantId, notificationSupport, 'notify', validateNotificationRequest, handler.notify.bind(handler),\r\n result => validatePresentationResult(result, validateAcceptedReceipt, 'Notification result'))\r\n}\r\n\r\nexport function userInteractionImplementation(\r\n participantId: string,\r\n spec: UserInteractionSupportSpec,\r\n handler: UserInteractionHandler,\r\n): CapabilityImplementation {\r\n const protocol = userInteractionSupport(spec)\r\n return Object.freeze({\r\n participantId,\r\n protocol,\r\n async handle(operationName: string, input: unknown, context: CapabilityHandlerContext) {\r\n if (operationName !== 'interact') throw new TypeError(`unsupported UserInteraction operation ${JSON.stringify(operationName)}`)\r\n validateUserInteractionRequest(input)\r\n if (!spec.operations.includes(input.kind)) throw new TypeError(`UserInteraction provider does not support ${JSON.stringify(input.kind)}`)\r\n const result = await handler.interact(input as never, context)\r\n return validateInteractionResult(input, result)\r\n },\r\n })\r\n}\r\n\r\nexport function validatePresentationDescriptor(value: unknown): asserts value is PresentationDescriptor {\r\n const descriptor = exactRecord(value, ['clientId', 'contracts'], ['clientId', 'contracts'], 'Presentation descriptor')\r\n nonEmpty(descriptor.clientId, 'Presentation descriptor.clientId')\r\n if (!Array.isArray(descriptor.contracts)) throw new TypeError('Presentation descriptor.contracts must be an array')\r\n const seen = new Set<string>()\r\n for (const [index, contractValue] of descriptor.contracts.entries()) {\r\n const contract = exactRecord(contractValue, ['apiVersion', 'kind', 'spec'], ['apiVersion', 'kind'], `Presentation descriptor.contracts[${index}]`)\r\n nonEmpty(contract.apiVersion, `Presentation descriptor.contracts[${index}].apiVersion`)\r\n nonEmpty(contract.kind, `Presentation descriptor.contracts[${index}].kind`)\r\n const key = `${String(contract.apiVersion)}\\0${String(contract.kind)}`\r\n if (seen.has(key)) throw new TypeError(`Presentation descriptor contains duplicate contract ${JSON.stringify(key)}`)\r\n seen.add(key)\r\n }\r\n}\r\n\r\nexport function validateOpenExternalRequest(value: unknown): asserts value is OpenExternalRequest {\r\n const request = requestRecord(value, ['uri'], 'OpenExternal request')\r\n nonEmpty(request.uri, 'OpenExternal request.uri')\r\n const uri = new URL(request.uri as string)\r\n if (uri.protocol !== 'https:' && uri.protocol !== 'http:') throw new TypeError('OpenExternal only accepts HTTP(S) URIs')\r\n}\r\n\r\nexport function validateCopyTextRequest(value: unknown): asserts value is CopyTextRequest {\r\n const request = requestRecord(value, ['text', 'sensitivity'], 'CopyText request')\r\n nonEmpty(request.text, 'CopyText request.text')\r\n if (request.sensitivity !== undefined && request.sensitivity !== 'public' && request.sensitivity !== 'private') {\r\n throw new TypeError('CopyText request.sensitivity is invalid')\r\n }\r\n}\r\n\r\nexport function validateNotificationRequest(value: unknown): asserts value is NotificationRequest {\r\n const request = requestRecord(value, ['text', 'level', 'deduplicationKey'], 'Notification request')\r\n nonEmpty(request.text, 'Notification request.text')\r\n if (request.level !== undefined && request.level !== 'info' && request.level !== 'warning' && request.level !== 'error') {\r\n throw new TypeError('Notification request.level is invalid')\r\n }\r\n if (request.deduplicationKey !== undefined) nonEmpty(request.deduplicationKey, 'Notification request.deduplicationKey')\r\n}\r\n\r\nexport function validateUserInteractionRequest(value: unknown): asserts value is UserInteractionRequest {\r\n if (!record(value)) throw new TypeError('UserInteraction request must be an object')\r\n if (value.kind === 'question') return validateQuestionRequest(value)\r\n if (value.kind === 'approval') return validateApprovalRequest(value)\r\n if (value.kind === 'secret-input') return validateSecretInputRequest(value)\r\n throw new TypeError('UserInteraction request.kind is invalid')\r\n}\r\n\r\nexport function validateUserInteractionRequirement(value: unknown): UserInteractionRequirementSpec {\r\n const spec = exactRecord(value, ['operations', 'optionalOperations'], ['operations'], 'UserInteraction requirement spec')\r\n const operations = operationList(spec.operations, 'UserInteraction requirement spec.operations')\r\n const optionalOperations = spec.optionalOperations === undefined\r\n ? undefined\r\n : operationList(spec.optionalOperations, 'UserInteraction requirement spec.optionalOperations')\r\n if (optionalOperations?.some(operation => operations.includes(operation)) === true) {\r\n throw new TypeError('UserInteraction optionalOperations must not duplicate required operations')\r\n }\r\n return deepFreeze({ operations, ...(optionalOperations === undefined ? {} : { optionalOperations }) })\r\n}\r\n\r\nexport function validateUserInteractionSupport(value: unknown): UserInteractionSupportSpec {\r\n const spec = exactRecord(value, ['operations', 'limits'], ['operations'], 'UserInteraction support spec')\r\n const operations = operationList(spec.operations, 'UserInteraction support spec.operations')\r\n const limits = spec.limits === undefined ? undefined : validateLimits(spec.limits)\r\n return deepFreeze({ operations, ...(limits === undefined ? {} : { limits }) })\r\n}\r\n\r\nfunction negotiateUserInteraction(\r\n input: ProtocolNegotiationInput<UserInteractionRequirementSpec, UserInteractionSupportSpec>,\r\n) {\r\n const issues: ProtocolIssue[] = []\r\n const bindings: Array<{\r\n readonly consumer: string\r\n readonly provider: string\r\n readonly requirement: ProtocolRequirement<UserInteractionRequirementSpec>\r\n readonly support: ProtocolSupport<UserInteractionSupportSpec>\r\n }> = []\r\n const connectionPolicy = connectionNegotiationPolicy(input.policy)\r\n for (const row of input.requirements) {\r\n const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant]\r\n const candidates = input.supports.filter(candidate => {\r\n if (candidate.participant === row.participant) return false\r\n if (consumerEndpoint !== undefined && connectionPolicy?.endpointByParticipant[candidate.participant] === consumerEndpoint) return false\r\n return row.requirement.spec!.operations.every(operation => candidate.support.spec!.operations.includes(operation))\r\n })\r\n if (candidates.length === 0) {\r\n issues.push(Object.freeze({\r\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\r\n severity: row.requirement.optional === true ? 'warning' : 'error',\r\n participant: row.participant,\r\n message: `no participant supports the required ${USER_INTERACTION_KIND} operations`,\r\n }))\r\n continue\r\n }\r\n if (candidates.length > 1) {\r\n issues.push(Object.freeze({\r\n code: 'support-ambiguous', severity: 'error', participant: row.participant,\r\n message: `multiple participants support ${API_VERSION} ${USER_INTERACTION_KIND}`,\r\n }))\r\n continue\r\n }\r\n const provider = candidates[0]!\r\n bindings.push(Object.freeze({\r\n consumer: row.participant,\r\n provider: provider.participant,\r\n requirement: row.requirement,\r\n support: provider.support,\r\n }))\r\n for (const operation of row.requirement.spec!.optionalOperations ?? []) {\r\n if (provider.support.spec!.operations.includes(operation)) continue\r\n issues.push(Object.freeze({\r\n code: 'optional-operation-missing', severity: 'warning', participant: row.participant,\r\n message: `${USER_INTERACTION_KIND} provider does not support optional operation ${JSON.stringify(operation)}`,\r\n }))\r\n }\r\n }\r\n return {\r\n agreement: Object.freeze({ kind: 'CapabilityBindings' as const, bindings: Object.freeze(bindings) }),\r\n issues: Object.freeze(issues),\r\n }\r\n}\r\n\r\nfunction connectionNegotiationPolicy(value: unknown): ConnectionNegotiationPolicy | undefined {\r\n return record(value) && record(value.endpointByParticipant)\r\n ? value as unknown as ConnectionNegotiationPolicy\r\n : undefined\r\n}\r\n\r\nfunction implementation<TInput, TOutput>(\r\n participantId: string,\r\n protocol: ProtocolSupport,\r\n operationName: string,\r\n validateInput: (value: unknown) => asserts value is TInput,\r\n handler: (input: TInput, context: CapabilityHandlerContext) => TOutput | Promise<TOutput>,\r\n validateOutput: (value: unknown) => TOutput,\r\n): CapabilityImplementation {\r\n return Object.freeze({\r\n participantId,\r\n protocol,\r\n async handle(operation: string, input: unknown, context: CapabilityHandlerContext) {\r\n if (operation !== operationName) throw new TypeError(`unsupported ${protocol.kind} operation ${JSON.stringify(operation)}`)\r\n validateInput(input)\r\n return validateOutput(await handler(input, context))\r\n },\r\n })\r\n}\r\n\r\nfunction validateQuestionRequest(value: unknown): asserts value is QuestionRequest {\r\n const request = requestRecord(value, ['kind', 'title', 'description', 'fields'], 'Question request')\r\n if (request.kind !== 'question') throw new TypeError('Question request.kind must be \"question\"')\r\n optionalText(request.title, 'Question request.title')\r\n optionalText(request.description, 'Question request.description')\r\n if (!Array.isArray(request.fields) || request.fields.length === 0) throw new TypeError('Question request.fields must be a non-empty array')\r\n const ids = new Set<string>()\r\n for (const [index, fieldValue] of request.fields.entries()) {\r\n const label = `Question request.fields[${index}]`\r\n if (!record(fieldValue)) throw new TypeError(`${label} must be an object`)\r\n const common = ['id', 'kind', 'label', 'description', 'required']\r\n const allowed = fieldValue.kind === 'text' ? [...common, 'multiline', 'minLength', 'maxLength']\r\n : fieldValue.kind === 'select' ? [...common, 'multiple', 'options'] : common\r\n const field = exactRecord(fieldValue, allowed, ['id', 'kind', 'label'], label)\r\n localId(field.id, `${label}.id`)\r\n if (ids.has(field.id as string)) throw new TypeError('Question request contains duplicate field id')\r\n ids.add(field.id as string)\r\n nonEmpty(field.label, `${label}.label`)\r\n optionalText(field.description, `${label}.description`)\r\n optionalBoolean(field.required, `${label}.required`)\r\n if (field.kind === 'text') {\r\n optionalBoolean(field.multiline, `${label}.multiline`)\r\n lengthBounds(field.minLength, field.maxLength, label)\r\n } else if (field.kind === 'select') {\r\n optionalBoolean(field.multiple, `${label}.multiple`)\r\n if (!Array.isArray(field.options) || field.options.length === 0) throw new TypeError(`${label}.options must be a non-empty array`)\r\n const options = new Set<string>()\r\n for (const [optionIndex, optionValue] of field.options.entries()) {\r\n const optionLabel = `${label}.options[${optionIndex}]`\r\n const option = exactRecord(optionValue, ['id', 'label', 'description'], ['id', 'label'], optionLabel)\r\n localId(option.id, `${optionLabel}.id`)\r\n if (options.has(option.id as string)) throw new TypeError(`${label} contains duplicate option id`)\r\n options.add(option.id as string)\r\n nonEmpty(option.label, `${optionLabel}.label`)\r\n optionalText(option.description, `${optionLabel}.description`)\r\n }\r\n } else if (field.kind !== 'confirm') {\r\n throw new TypeError(`${label}.kind is invalid`)\r\n }\r\n }\r\n}\r\n\r\nfunction validateApprovalRequest(value: unknown): asserts value is ApprovalRequest {\r\n const request = requestRecord(value, ['kind', 'action', 'summary', 'details', 'risk'], 'Approval request')\r\n if (request.kind !== 'approval') throw new TypeError('Approval request.kind must be \"approval\"')\r\n nonEmpty(request.action, 'Approval request.action')\r\n nonEmpty(request.summary, 'Approval request.summary')\r\n if (request.risk !== undefined && request.risk !== 'low' && request.risk !== 'medium' && request.risk !== 'high') {\r\n throw new TypeError('Approval request.risk is invalid')\r\n }\r\n if (request.details !== undefined) {\r\n if (!Array.isArray(request.details)) throw new TypeError('Approval request.details must be an array')\r\n for (const [index, detailValue] of request.details.entries()) {\r\n const label = `Approval request.details[${index}]`\r\n const detail = exactRecord(detailValue, ['label', 'value', 'sensitivity'], ['label', 'value'], label)\r\n nonEmpty(detail.label, `${label}.label`)\r\n nonEmpty(detail.value, `${label}.value`)\r\n if (detail.sensitivity !== undefined && detail.sensitivity !== 'public' && detail.sensitivity !== 'private') {\r\n throw new TypeError(`${label}.sensitivity is invalid`)\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction validateSecretInputRequest(value: unknown): asserts value is SecretInputRequest {\r\n const request = requestRecord(value, ['kind', 'label', 'description', 'minLength', 'maxLength'], 'SecretInput request')\r\n if (request.kind !== 'secret-input') throw new TypeError('SecretInput request.kind must be \"secret-input\"')\r\n nonEmpty(request.label, 'SecretInput request.label')\r\n optionalText(request.description, 'SecretInput request.description')\r\n lengthBounds(request.minLength, request.maxLength, 'SecretInput request')\r\n}\r\n\r\nfunction validateInteractionResult(\r\n request: UserInteractionRequest,\r\n value: unknown,\r\n): PresentationResult<UserInteractionValue> {\r\n if (request.kind === 'question') return validatePresentationResult(value, result => validateQuestionAnswers(request, result), 'Question result')\r\n if (request.kind === 'approval') return validatePresentationResult(value, validateApprovalValue, 'Approval result')\r\n return validatePresentationResult(value, result => validateSecretInputValue(request, result), 'SecretInput result')\r\n}\r\n\r\nfunction validateQuestionAnswers(request: QuestionRequest, value: unknown): QuestionAnswers {\r\n const result = exactRecord(value, ['answers'], ['answers'], 'Question answers')\r\n if (!record(result.answers)) throw new TypeError('Question answers.answers must be an object')\r\n const fields = new Map(request.fields.map(field => [field.id, field]))\r\n for (const field of request.fields) {\r\n if (field.required === true && !Object.hasOwn(result.answers, field.id)) throw new TypeError(`Question answers is missing required field ${JSON.stringify(field.id)}`)\r\n }\r\n for (const [id, answer] of Object.entries(result.answers)) {\r\n const field = fields.get(id)\r\n if (field === undefined) throw new TypeError(`Question answers contains unknown field ${JSON.stringify(id)}`)\r\n if (field.kind === 'text') {\r\n if (typeof answer !== 'string') throw new TypeError(`Question answer ${JSON.stringify(id)} must be a string`)\r\n if (field.minLength !== undefined && answer.length < field.minLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too short`)\r\n if (field.maxLength !== undefined && answer.length > field.maxLength) throw new TypeError(`Question answer ${JSON.stringify(id)} is too long`)\r\n } else if (field.kind === 'confirm') {\r\n if (typeof answer !== 'boolean') throw new TypeError(`Question answer ${JSON.stringify(id)} must be boolean`)\r\n } else {\r\n const allowed = new Set(field.options.map(option => option.id))\r\n const selected = field.multiple === true ? answer : [answer]\r\n if (!Array.isArray(selected) || selected.some(option => typeof option !== 'string' || !allowed.has(option))) {\r\n throw new TypeError(`Question answer ${JSON.stringify(id)} contains an invalid option`)\r\n }\r\n }\r\n }\r\n return freezeClone(value as QuestionAnswers)\r\n}\r\n\r\nfunction validateApprovalValue(value: unknown): ApprovalValue {\r\n const result = exactRecord(value, ['decision'], ['decision'], 'Approval value')\r\n if (result.decision !== 'approved' && result.decision !== 'denied') throw new TypeError('Approval value.decision is invalid')\r\n return freezeClone(value as ApprovalValue)\r\n}\r\n\r\nfunction validateSecretInputValue(request: SecretInputRequest, value: unknown): SecretInputValue {\r\n const result = exactRecord(value, ['secret'], ['secret'], 'SecretInput value')\r\n if (typeof result.secret !== 'string') throw new TypeError('SecretInput value.secret must be a string')\r\n if (request.minLength !== undefined && result.secret.length < request.minLength) throw new TypeError('SecretInput value.secret is too short')\r\n if (request.maxLength !== undefined && result.secret.length > request.maxLength) throw new TypeError('SecretInput value.secret is too long')\r\n return freezeClone(value as SecretInputValue)\r\n}\r\n\r\nfunction validatePresentationResult<T>(\r\n value: unknown,\r\n validateSubmitted: (submitted: unknown) => T,\r\n label: string,\r\n): PresentationResult<T> {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n if (value.status === 'submitted') {\r\n const result = exactRecord(value, ['status', 'value'], ['status', 'value'], label)\r\n return deepFreeze({ status: 'submitted' as const, value: validateSubmitted(result.value) })\r\n }\r\n if (value.status === 'unavailable') {\r\n const result = exactRecord(value, ['status', 'reason'], ['status'], label)\r\n optionalText(result.reason, `${label}.reason`)\r\n return freezeClone(value as PresentationResult<T>)\r\n }\r\n if (value.status === 'cancelled' || value.status === 'expired') {\r\n exactRecord(value, ['status'], ['status'], label)\r\n return freezeClone(value as PresentationResult<T>)\r\n }\r\n throw new TypeError(`${label}.status is invalid`)\r\n}\r\n\r\nfunction validateAcceptedReceipt(value: unknown): { readonly accepted: true } {\r\n const receipt = exactRecord(value, ['accepted'], ['accepted'], 'Presentation receipt')\r\n if (receipt.accepted !== true) throw new TypeError('Presentation receipt.accepted must be true')\r\n return Object.freeze({ accepted: true })\r\n}\r\n\r\nfunction requestRecord(value: unknown, fields: readonly string[], label: string): Record<string, unknown> {\r\n const required = ['requestId', 'invocationId', 'origin', ...fields.filter(field => !['title', 'description', 'details', 'risk', 'level', 'deduplicationKey', 'sensitivity', 'minLength', 'maxLength'].includes(field))]\r\n const request = exactRecord(value, ['requestId', 'invocationId', 'origin', 'deadline', ...fields], required, label)\r\n nonEmpty(request.requestId, `${label}.requestId`)\r\n nonEmpty(request.invocationId, `${label}.invocationId`)\r\n nonEmpty(request.origin, `${label}.origin`)\r\n if (request.deadline !== undefined && (typeof request.deadline !== 'string' || Number.isNaN(Date.parse(request.deadline)))) {\r\n throw new TypeError(`${label}.deadline must be an RFC 3339 date-time`)\r\n }\r\n return request\r\n}\r\n\r\nfunction validateLimits(value: unknown): UserInteractionLimits {\r\n const limits = exactRecord(\r\n value,\r\n ['maxConcurrentRequests', 'maxFields', 'maxOptionsPerField', 'maxTextLength'],\r\n [],\r\n 'UserInteraction limits',\r\n )\r\n for (const [name, limit] of Object.entries(limits)) positiveInteger(limit, `UserInteraction limits.${name}`)\r\n return freezeClone(value as UserInteractionLimits)\r\n}\r\n\r\nfunction operationList(value: unknown, label: string): readonly UserInteractionOperation[] {\r\n if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)\r\n const operations = value.map(operation => {\r\n if (operation !== 'question' && operation !== 'approval' && operation !== 'secret-input') throw new TypeError(`${label} contains an invalid operation`)\r\n return operation\r\n })\r\n if (new Set(operations).size !== operations.length) throw new TypeError(`${label} contains a duplicate operation`)\r\n return Object.freeze(operations)\r\n}\r\n\r\nfunction lengthBounds(minimum: unknown, maximum: unknown, label: string): void {\r\n if (minimum !== undefined) nonNegativeInteger(minimum, `${label}.minLength`)\r\n if (maximum !== undefined) nonNegativeInteger(maximum, `${label}.maxLength`)\r\n if (typeof minimum === 'number' && typeof maximum === 'number' && minimum > maximum) {\r\n throw new TypeError(`${label}.minLength must not exceed maxLength`)\r\n }\r\n}\r\n\r\nfunction exactRecord(value: unknown, allowed: readonly string[], required: readonly string[], label: string): Record<string, unknown> {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n const unknown = Object.keys(value).filter(key => !allowed.includes(key))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n for (const key of required) if (!Object.hasOwn(value, key)) throw new TypeError(`${label}.${key} is required`)\r\n return value\r\n}\r\n\r\nfunction record(value: unknown): value is Record<string, unknown> {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value)\r\n}\r\n\r\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n\r\nfunction validateInvocationScope(scope: PresentationInvocationScope): void {\r\n if (!record(scope)) throw new TypeError('Presentation invocation scope must be an object')\r\n nonEmpty(scope.invocationId, 'Presentation invocation scope.invocationId')\r\n nonEmpty(scope.origin, 'Presentation invocation scope.origin')\r\n if (scope.deadline !== undefined && (typeof scope.deadline !== 'string' || Number.isNaN(Date.parse(scope.deadline)))) {\r\n throw new TypeError('Presentation invocation scope.deadline must be an RFC 3339 date-time')\r\n }\r\n if (typeof scope.nextRequestId !== 'function') throw new TypeError('Presentation invocation scope.nextRequestId must be a function')\r\n}\r\n\r\nfunction requestFactory(scope: PresentationInvocationScope) {\r\n validateInvocationScope(scope)\r\n return <T extends object>(input: T): Readonly<T & PresentationRequestContext> => {\r\n if (!record(input)) throw new TypeError('Presentation input must be an object')\r\n const requestId = scope.nextRequestId()\r\n nonEmpty(requestId, 'Presentation requestId')\r\n return freezeClone({\r\n ...input,\r\n requestId,\r\n invocationId: scope.invocationId,\r\n origin: scope.origin,\r\n ...(scope.deadline === undefined ? {} : { deadline: scope.deadline }),\r\n })\r\n }\r\n}\r\n\r\nfunction optionalText(value: unknown, label: string): void {\r\n if (value !== undefined) nonEmpty(value, label)\r\n}\r\n\r\nfunction optionalBoolean(value: unknown, label: string): void {\r\n if (value !== undefined && typeof value !== 'boolean') throw new TypeError(`${label} must be boolean`)\r\n}\r\n\r\nfunction localId(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || !/^[A-Za-z][A-Za-z0-9._-]*$/u.test(value)) throw new TypeError(`${label} is invalid`)\r\n}\r\n\r\nfunction positiveInteger(value: unknown, label: string): void {\r\n if (!Number.isSafeInteger(value) || (value as number) < 1) throw new TypeError(`${label} must be a positive safe integer`)\r\n}\r\n\r\nfunction nonNegativeInteger(value: unknown, label: string): void {\r\n if (!Number.isSafeInteger(value) || (value as number) < 0) throw new TypeError(`${label} must be a non-negative safe integer`)\r\n}\r\n\r\nfunction freezeClone<T>(value: T): T { return deepFreeze(structuredClone(value)) }\r\n\r\nfunction deepFreeze<T>(value: T): T {\r\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return value\r\n Object.freeze(value)\r\n for (const child of Object.values(value)) deepFreeze(child)\r\n return value\r\n}\r\n"],"mappings":";;;AAoBA,MAAa,cAAc;AAC3B,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,wBAAwB;AAqMrC,MAAM,aAAa,UAA8B;CAC/C,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,UAAU,yDAAyD;AAExG;AAEA,MAAa,uBAAuB,yBAAyB;CAC3D,YAAY;CAAa,MAAM;CAAoB,qBAAqB;CAAW,iBAAiB;AACtG,CAAC;AACD,MAAa,mBAAmB,yBAAyB;CACvD,YAAY;CAAa,MAAM;CAAgB,qBAAqB;CAAW,iBAAiB;AAClG,CAAC;AACD,MAAa,uBAAuB,yBAAyB;CAC3D,YAAY;CAAa,MAAM;CAAmB,qBAAqB;CAAW,iBAAiB;AACrG,CAAC;AAED,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAmB,CAAC;AACvH,MAAa,kBAAmC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAe,CAAC;AAC/G,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAkB,CAAC;AACtH,MAAa,0BAA0B,SACrC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;CAAuB,MAAM,+BAA+B,IAAI;AAAE,CAAC;AAEpH,MAAa,0BAGT,OAAO,OAAO;CAChB,YAAY;CACZ,MAAM;CACN,qBAAqB;CACrB,iBAAiB;CACjB,WAAW;AACb,CAAC;AAED,MAAa,YAA2C,OAAO,OAAO;CACpE;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAA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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,qBAAqB;CAAW,iBAAiB;AACrG,CAAC;AAED,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAmB,CAAC;AACvH,MAAa,kBAAmC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAe,CAAC;AAC/G,MAAa,sBAAuC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;AAAkB,CAAC;AACtH,MAAa,0BAA0B,SACrC,OAAO,OAAO;CAAE,YAAY;CAAa,MAAM;CAAuB,MAAM,+BAA+B,IAAI;AAAE,CAAC;AAEpH,MAAa,0BAGT,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AAmB,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,25 +1,25 @@
1
- {
2
- "name": "@dsh-std/presentation",
3
- "version": "0.1.0",
4
- "license": "MIT",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
8
- "exports": {
9
- ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
10
- "./operations": { "types": "./lib/operations.d.ts", "default": "./lib/operations.js" },
11
- "./interaction": { "types": "./lib/interaction.d.ts", "default": "./lib/interaction.js" },
12
- "./callback": { "types": "./lib/callback.d.ts", "default": "./lib/callback.js" }
13
- },
14
- "files": ["lib", "CHANGELOG.md"],
15
- "scripts": {
16
- "build": "pnpm run typecheck && tsdown",
17
- "typecheck": "tsc -p tsconfig.json --noEmit",
18
- "test": "vitest run --passWithNoTests"
19
- },
20
- "dependencies": {
21
- "@dsh-std/core": "workspace:*",
22
- "@dsh-std/connection": "workspace:*"
23
- },
24
- "engines": { "node": "^22.19 || >=24" }
25
- }
1
+ {
2
+ "name": "@dsh-std/presentation",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
10
+ "./operations": { "types": "./lib/operations.d.ts", "default": "./lib/operations.js" },
11
+ "./interaction": { "types": "./lib/interaction.d.ts", "default": "./lib/interaction.js" },
12
+ "./callback": { "types": "./lib/callback.d.ts", "default": "./lib/callback.js" }
13
+ },
14
+ "files": ["lib", "CHANGELOG.md"],
15
+ "scripts": {
16
+ "build": "pnpm run typecheck && tsdown",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "test": "vitest run --passWithNoTests"
19
+ },
20
+ "dependencies": {
21
+ "@dsh-std/core": "workspace:*",
22
+ "@dsh-std/connection": "workspace:*"
23
+ },
24
+ "engines": { "node": "^22.19 || >=24" }
25
+ }
@@ -1,8 +1,8 @@
1
- # Changelog
2
-
3
- Changes to `@dsh-std/storage` are recorded here.
4
-
5
- ## 0.1.0 (draft)
6
-
7
- - Defined scoped local JSON storage get, set, and delete operations.
8
- - Added permission names, schemas, validators, and deterministic provider negotiation.
1
+ # Changelog
2
+
3
+ Changes to `@dsh-std/storage` are recorded here.
4
+
5
+ ## 0.1.0 (draft)
6
+
7
+ - Defined scoped local JSON storage get, set, and delete operations.
8
+ - Added permission names, schemas, validators, and deterministic provider negotiation.
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 DSH Standard contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH Standard contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,5 @@
1
- # @dsh-std/storage
2
-
3
- English | [中文](README.zh.md)
4
-
5
- This package defines the Community v0.15 `storage.dsh/v1alpha1` `LocalStorage` coordinates, negotiation definition, JSON data model, and operation validators. Concrete storage backends and product authorization interfaces are supplied by implementations.
1
+ # @dsh-std/storage
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ This package defines the Community v0.15 `storage.dsh/v1alpha1` `LocalStorage` coordinates, negotiation definition, JSON data model, and operation validators. Concrete storage backends and product authorization interfaces are supplied by implementations.
@@ -1,7 +1,7 @@
1
- # @dsh-std/storage
2
-
3
- [English](README.md) | 中文
4
-
5
- 规范见 [Local Component Storage](../../docs/proposals/storage.zh.md)。
6
-
7
- 本包定义 Community v0.15 的 `storage.dsh/v1alpha1` `LocalStorage` 协议坐标、协商 definition、JSON 数据类型和操作校验器。具体存储后端与产品授权界面由实现提供。
1
+ # @dsh-std/storage
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 规范见 [Local Component Storage](../../docs/proposals/storage.zh.md)。
6
+
7
+ 本包定义 Community v0.15 的 `storage.dsh/v1alpha1` `LocalStorage` 协议坐标、协商 definition、JSON 数据类型和操作校验器。具体存储后端与产品授权界面由实现提供。
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\r\n ProtocolCatalog,\r\n ProtocolDefinition,\r\n ProtocolIssue,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\n\r\nexport const API_VERSION = 'storage.dsh/v1alpha1'\r\nexport const KIND = 'LocalStorage'\r\n\r\nexport const READ_PERMISSION = 'storage.local.read'\r\nexport const WRITE_PERMISSION = 'storage.local.write'\r\n\r\nexport type JsonPrimitive = null | boolean | number | string\r\nexport type JsonValue = JsonPrimitive | readonly JsonValue[] | { readonly [key: string]: JsonValue }\r\n\r\nexport interface LocalStorageGetInput {\r\n readonly key: string\r\n}\r\n\r\nexport interface LocalStorageGetOutput {\r\n readonly value: JsonValue | null\r\n}\r\n\r\nexport interface LocalStorageSetInput {\r\n readonly key: string\r\n readonly value: JsonValue\r\n}\r\n\r\nexport interface LocalStorageSetOutput {\r\n readonly stored: true\r\n}\r\n\r\nexport interface LocalStorageDeleteInput {\r\n readonly key: string\r\n}\r\n\r\nexport interface LocalStorageDeleteOutput {\r\n readonly deleted: boolean\r\n}\r\n\r\nexport interface LocalStorage {\r\n get(input: LocalStorageGetInput): LocalStorageGetOutput | Promise<LocalStorageGetOutput>\r\n set(input: LocalStorageSetInput): LocalStorageSetOutput | Promise<LocalStorageSetOutput>\r\n delete(input: LocalStorageDeleteInput): LocalStorageDeleteOutput | Promise<LocalStorageDeleteOutput>\r\n}\r\n\r\nexport type LocalStorageErrorCode =\r\n | 'PERMISSION_NOT_GRANTED'\r\n | 'INVALID_KEY'\r\n | 'INVALID_VALUE'\r\n | 'QUOTA_EXCEEDED'\r\n | 'STORAGE_UNAVAILABLE'\r\n\r\nexport const protocol: ProtocolDefinition = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: KIND,\r\n validateRequirement: emptySpec,\r\n validateSupport: emptySpec,\r\n negotiate: negotiateProvider,\r\n})\r\n\r\nexport const support: ProtocolSupport = Object.freeze({\r\n apiVersion: API_VERSION,\r\n kind: KIND,\r\n})\r\n\r\nexport function register(catalog: ProtocolCatalog): () => void {\r\n return catalog.register(protocol)\r\n}\r\n\r\nexport function validateGetInput(value: unknown): asserts value is LocalStorageGetInput {\r\n const input = exactRecord(value, ['key'], 'LocalStorage.get input')\r\n key(input.key, 'LocalStorage.get input.key')\r\n}\r\n\r\nexport function validateSetInput(value: unknown): asserts value is LocalStorageSetInput {\r\n const input = exactRecord(value, ['key', 'value'], 'LocalStorage.set input')\r\n key(input.key, 'LocalStorage.set input.key')\r\n validateJsonValue(input.value, 'LocalStorage.set input.value')\r\n}\r\n\r\nexport function validateDeleteInput(value: unknown): asserts value is LocalStorageDeleteInput {\r\n const input = exactRecord(value, ['key'], 'LocalStorage.delete input')\r\n key(input.key, 'LocalStorage.delete input.key')\r\n}\r\n\r\nexport function validateGetOutput(value: unknown): asserts value is LocalStorageGetOutput {\r\n const output = exactRecord(value, ['value'], 'LocalStorage.get output')\r\n validateJsonValue(output.value, 'LocalStorage.get output.value')\r\n}\r\n\r\nexport function validateSetOutput(value: unknown): asserts value is LocalStorageSetOutput {\r\n const output = exactRecord(value, ['stored'], 'LocalStorage.set output')\r\n if (output.stored !== true) throw new TypeError('LocalStorage.set output.stored must be true')\r\n}\r\n\r\nexport function validateDeleteOutput(value: unknown): asserts value is LocalStorageDeleteOutput {\r\n const output = exactRecord(value, ['deleted'], 'LocalStorage.delete output')\r\n if (typeof output.deleted !== 'boolean') throw new TypeError('LocalStorage.delete output.deleted must be boolean')\r\n}\r\n\r\nexport function validateJsonValue(value: unknown, label = 'JSON value'): asserts value is JsonValue {\r\n jsonValue(value, label, new Set<object>())\r\n}\r\n\r\nfunction negotiateProvider(input: Parameters<NonNullable<ProtocolDefinition['negotiate']>>[0]) {\r\n const issues: ProtocolIssue[] = []\r\n const providers = new Map<string, string>()\r\n for (const row of input.requirements) {\r\n const candidates = input.supports.filter(candidate => candidate.participant !== row.participant)\r\n if (candidates.length === 0) {\r\n issues.push(Object.freeze({\r\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\r\n severity: row.requirement.optional === true ? 'warning' : 'error',\r\n participant: row.participant,\r\n message: `no participant supports ${API_VERSION} ${KIND}`,\r\n }))\r\n } else if (candidates.length > 1) {\r\n issues.push(Object.freeze({\r\n code: 'support-ambiguous',\r\n severity: 'error',\r\n participant: row.participant,\r\n message: `multiple participants support ${API_VERSION} ${KIND}`,\r\n }))\r\n } else {\r\n providers.set(row.participant, candidates[0]!.participant)\r\n }\r\n }\r\n return {\r\n agreement: Object.freeze({\r\n kind: 'LocalStorageBindings',\r\n providers: Object.freeze(Object.fromEntries([...providers].sort(([left], [right]) => left.localeCompare(right)))),\r\n }),\r\n issues: Object.freeze(issues),\r\n }\r\n}\r\n\r\nfunction emptySpec(value: unknown): undefined {\r\n if (value !== undefined) throw new TypeError(`${KIND} does not accept spec in v1alpha1`)\r\n return undefined\r\n}\r\n\r\nfunction jsonValue(value: unknown, label: string, ancestors: Set<object>): void {\r\n if (value === null || typeof value === 'boolean' || typeof value === 'string') return\r\n if (typeof value === 'number') {\r\n if (!Number.isFinite(value)) throw new TypeError(`${label} must contain only finite numbers`)\r\n return\r\n }\r\n if (typeof value !== 'object') throw new TypeError(`${label} must be a JSON value`)\r\n if (ancestors.has(value)) throw new TypeError(`${label} must not contain cycles`)\r\n ancestors.add(value)\r\n if (Array.isArray(value)) {\r\n for (const [index, item] of value.entries()) jsonValue(item, `${label}[${index}]`, ancestors)\r\n } else {\r\n const prototype = Object.getPrototypeOf(value)\r\n if (prototype !== Object.prototype && prototype !== null) throw new TypeError(`${label} must contain only plain objects`)\r\n for (const [name, item] of Object.entries(value)) jsonValue(item, `${label}.${name}`, ancestors)\r\n }\r\n ancestors.delete(value)\r\n}\r\n\r\nfunction exactRecord(value: unknown, allowed: readonly string[], label: string): Record<string, unknown> {\r\n if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError(`${label} must be an object`)\r\n const record = value as Record<string, unknown>\r\n const unknown = Object.keys(record).filter(name => !allowed.includes(name))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n for (const name of allowed) {\r\n if (!Object.hasOwn(record, name)) throw new TypeError(`${label}.${name} is required`)\r\n }\r\n return record\r\n}\r\n\r\nfunction key(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.length === 0) throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n"],"mappings":";AAOA,MAAa,cAAc;AAC3B,MAAa,OAAO;AAEpB,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AA2ChC,MAAa,WAA+B,OAAO,OAAO;CACxD,YAAY;CACZ,MAAM;CACN,qBAAqB;CACrB,iBAAiB;CACjB,WAAW;AACb,CAAC;AAED,MAAa,UAA2B,OAAO,OAAO;CACpD,YAAY;CACZ,MAAM;AACR,CAAC;AAED,SAAgB,SAAS,SAAsC;CAC7D,OAAO,QAAQ,SAAS,QAAQ;AAClC;AAEA,SAAgB,iBAAiB,OAAuD;CAEtF,IADc,YAAY,OAAO,CAAC,KAAK,GAAG,wBAClC,CAAC,CAAC,KAAK,4BAA4B;AAC7C;AAEA,SAAgB,iBAAiB,OAAuD;CACtF,MAAM,QAAQ,YAAY,OAAO,CAAC,O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AwC;CACvG,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;CACzH,MAAM,SAAS;CACf,MAAM,UAAU,OAAO,KAAK,MAAM,CAAC,CAAC,QAAO,SAAQ,CAAC,QAAQ,SAAS,IAAI,CAAC;CAC1E,IAAI,QAAQ,SAAS,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,0BAA0B,KAAK,UAAU,QAAQ,EAAE,GAAG;CAC3G,KAAK,MAAM,QAAQ,SACjB,IAAI,CAAC,OAAO,OAAO,QAAQ,IAAI,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,GAAG,KAAK,aAAa;CAEtF,OAAO;AACT;AAEA,SAAS,IAAI,OAAgB,OAAwC;CACnE,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,4BAA4B;AAChH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\n ProtocolCatalog,\n ProtocolDefinition,\n ProtocolIssue,\n ProtocolSupport,\n} from '@dsh-std/core'\n\nexport const API_VERSION = 'storage.dsh/v1alpha1'\nexport const KIND = 'LocalStorage'\n\nexport const READ_PERMISSION = 'storage.local.read'\nexport const WRITE_PERMISSION = 'storage.local.write'\n\nexport type JsonPrimitive = null | boolean | number | string\nexport type JsonValue = JsonPrimitive | readonly JsonValue[] | { readonly [key: string]: JsonValue }\n\nexport interface LocalStorageGetInput {\n readonly key: string\n}\n\nexport interface LocalStorageGetOutput {\n readonly value: JsonValue | null\n}\n\nexport interface LocalStorageSetInput {\n readonly key: string\n readonly value: JsonValue\n}\n\nexport interface LocalStorageSetOutput {\n readonly stored: true\n}\n\nexport interface LocalStorageDeleteInput {\n readonly key: string\n}\n\nexport interface LocalStorageDeleteOutput {\n readonly deleted: boolean\n}\n\nexport interface LocalStorage {\n get(input: LocalStorageGetInput): LocalStorageGetOutput | Promise<LocalStorageGetOutput>\n set(input: LocalStorageSetInput): LocalStorageSetOutput | Promise<LocalStorageSetOutput>\n delete(input: LocalStorageDeleteInput): LocalStorageDeleteOutput | Promise<LocalStorageDeleteOutput>\n}\n\nexport type LocalStorageErrorCode =\n | 'PERMISSION_NOT_GRANTED'\n | 'INVALID_KEY'\n | 'INVALID_VALUE'\n | 'QUOTA_EXCEEDED'\n | 'STORAGE_UNAVAILABLE'\n\nexport const protocol: ProtocolDefinition = Object.freeze({\n apiVersion: API_VERSION,\n kind: KIND,\n validateRequirement: emptySpec,\n validateSupport: emptySpec,\n negotiate: negotiateProvider,\n})\n\nexport const support: ProtocolSupport = Object.freeze({\n apiVersion: API_VERSION,\n kind: KIND,\n})\n\nexport function register(catalog: ProtocolCatalog): () => void {\n return catalog.register(protocol)\n}\n\nexport function validateGetInput(value: unknown): asserts value is LocalStorageGetInput {\n const input = exactRecord(value, ['key'], 'LocalStorage.get input')\n key(input.key, 'LocalStorage.get input.key')\n}\n\nexport function validateSetInput(value: unknown): asserts value is LocalStorageSetInput {\n const input = exactRecord(value, ['key', 'value'], 'LocalStorage.set input')\n key(input.key, 'LocalStorage.set input.key')\n validateJsonValue(input.value, 'LocalStorage.set input.value')\n}\n\nexport function validateDeleteInput(value: unknown): asserts value is LocalStorageDeleteInput {\n const input = exactRecord(value, ['key'], 'LocalStorage.delete input')\n key(input.key, 'LocalStorage.delete input.key')\n}\n\nexport function validateGetOutput(value: unknown): asserts value is LocalStorageGetOutput {\n const output = exactRecord(value, ['value'], 'LocalStorage.get output')\n validateJsonValue(output.value, 'LocalStorage.get output.value')\n}\n\nexport function validateSetOutput(value: unknown): asserts value is LocalStorageSetOutput {\n const output = exactRecord(value, ['stored'], 'LocalStorage.set output')\n if (output.stored !== true) throw new TypeError('LocalStorage.set output.stored must be true')\n}\n\nexport function validateDeleteOutput(value: unknown): asserts value is LocalStorageDeleteOutput {\n const output = exactRecord(value, ['deleted'], 'LocalStorage.delete output')\n if (typeof output.deleted !== 'boolean') throw new TypeError('LocalStorage.delete output.deleted must be boolean')\n}\n\nexport function validateJsonValue(value: unknown, label = 'JSON value'): asserts value is JsonValue {\n jsonValue(value, label, new Set<object>())\n}\n\nfunction negotiateProvider(input: Parameters<NonNullable<ProtocolDefinition['negotiate']>>[0]) {\n const issues: ProtocolIssue[] = []\n const providers = new Map<string, string>()\n for (const row of input.requirements) {\n const candidates = input.supports.filter(candidate => candidate.participant !== row.participant)\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 ${API_VERSION} ${KIND}`,\n }))\n } else if (candidates.length > 1) {\n issues.push(Object.freeze({\n code: 'support-ambiguous',\n severity: 'error',\n participant: row.participant,\n message: `multiple participants support ${API_VERSION} ${KIND}`,\n }))\n } else {\n providers.set(row.participant, candidates[0]!.participant)\n }\n }\n return {\n agreement: Object.freeze({\n kind: 'LocalStorageBindings',\n providers: Object.freeze(Object.fromEntries([...providers].sort(([left], [right]) => left.localeCompare(right)))),\n }),\n issues: Object.freeze(issues),\n }\n}\n\nfunction emptySpec(value: unknown): undefined {\n if (value !== undefined) throw new TypeError(`${KIND} does not accept spec in v1alpha1`)\n return undefined\n}\n\nfunction jsonValue(value: unknown, label: string, ancestors: Set<object>): void {\n if (value === null || typeof value === 'boolean' || typeof value === 'string') return\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) throw new TypeError(`${label} must contain only finite numbers`)\n return\n }\n if (typeof value !== 'object') throw new TypeError(`${label} must be a JSON value`)\n if (ancestors.has(value)) throw new TypeError(`${label} must not contain cycles`)\n ancestors.add(value)\n if (Array.isArray(value)) {\n for (const [index, item] of value.entries()) jsonValue(item, `${label}[${index}]`, ancestors)\n } else {\n const prototype = Object.getPrototypeOf(value)\n if (prototype !== Object.prototype && prototype !== null) throw new TypeError(`${label} must contain only plain objects`)\n for (const [name, item] of Object.entries(value)) jsonValue(item, `${label}.${name}`, ancestors)\n }\n ancestors.delete(value)\n}\n\nfunction exactRecord(value: unknown, allowed: readonly string[], label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError(`${label} must be an object`)\n const record = value as Record<string, unknown>\n const unknown = Object.keys(record).filter(name => !allowed.includes(name))\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\n for (const name of allowed) {\n if (!Object.hasOwn(record, name)) throw new TypeError(`${label}.${name} is required`)\n }\n return record\n}\n\nfunction key(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.length === 0) throw new TypeError(`${label} must be a non-empty string`)\n}\n"],"mappings":";AAOA,MAAa,cAAc;AAC3B,MAAa,OAAO;AAEpB,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;AA2ChC,MAAa,WAA+B,OAAO,OAAO;CACxD,YAAY;CACZ,MAAM;CACN,qBAAqB;CACrB,iBAAiB;CACjB,WAAW;AACb,CAAC;AAED,MAAa,UAA2B,OAAO,OAAO;CACpD,YAAY;CACZ,MAAM;AACR,CAAC;AAED,SAAgB,SAAS,SAAsC;CAC7D,OAAO,QAAQ,SAAS,QAAQ;AAClC;AAEA,SAAgB,iBAAiB,OAAuD;CAEtF,IADc,YAAY,OAAO,CAAC,KAAK,GAAG,wBAClC,CAAC,CAAC,KAAK,4BAA4B;AAC7C;AAEA,SAAgB,iBAAiB,OAAuD;CACtF,MAAM,QAAQ,YAAY,OAAO,CAAC,OAAO,OAAO,GAAG,wBAAwB;CAC3E,IAAI,MAAM,KAAK,4BAA4B;CAC3C,kBAAkB,MAAM,OAAO,8BAA8B;AAC/D;AAEA,SAAgB,oBAAoB,OAA0D;CAE5F,IADc,YAAY,OAAO,CAAC,KAAK,GAAG,2BAClC,CAAC,CAAC,KAAK,+BAA+B;AAChD;AAEA,SAAgB,kBAAkB,OAAwD;CAExF,kBADe,YAAY,OAAO,CAAC,OAAO,GAA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M,0BAA0B,KAAK,UAAU,QAAQ,EAAE,GAAG;CAC3G,KAAK,MAAM,QAAQ,SACjB,IAAI,CAAC,OAAO,OAAO,QAAQ,IAAI,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,GAAG,KAAK,aAAa;CAEtF,OAAO;AACT;AAEA,SAAS,IAAI,OAAgB,OAAwC;CACnE,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,MAAM,IAAI,UAAU,GAAG,MAAM,4BAA4B;AAChH"}
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@dsh-std/storage",
3
- "version": "0.1.0",
4
- "license": "MIT",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
8
- "exports": {
9
- ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
10
- "./schema/local-storage-0.15.json": "./schema/local-storage-0.15.schema.json"
11
- },
12
- "files": ["lib", "schema", "CHANGELOG.md"],
13
- "scripts": {
14
- "build": "pnpm run typecheck && tsdown",
15
- "typecheck": "tsc -p tsconfig.json --noEmit",
16
- "test": "vitest run --passWithNoTests"
17
- },
18
- "dependencies": { "@dsh-std/core": "workspace:*" },
19
- "engines": { "node": "^22.19 || >=24" }
20
- }
1
+ {
2
+ "name": "@dsh-std/storage",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
10
+ "./schema/local-storage-0.15.json": "./schema/local-storage-0.15.schema.json"
11
+ },
12
+ "files": ["lib", "schema", "CHANGELOG.md"],
13
+ "scripts": {
14
+ "build": "pnpm run typecheck && tsdown",
15
+ "typecheck": "tsc -p tsconfig.json --noEmit",
16
+ "test": "vitest run --passWithNoTests"
17
+ },
18
+ "dependencies": { "@dsh-std/core": "workspace:*" },
19
+ "engines": { "node": "^22.19 || >=24" }
20
+ }