import { CapabilityClient, CapabilityHandlerContext, CapabilityImplementation } from "@dsh-std/connection"; import { ProtocolCatalog, ProtocolDefinition, ProtocolSupport } from "@dsh-std/core"; //#region src/index.d.ts declare const API_VERSION = "presentation.dsh/v1alpha1"; declare const OPEN_EXTERNAL_KIND = "OpenExternal"; declare const COPY_TEXT_KIND = "CopyText"; declare const NOTIFICATION_KIND = "Notification"; declare const USER_INTERACTION_KIND = "UserInteraction"; interface PresentationDescriptor { /** Endpoint identity selected and authenticated by the Host for this invocation. */ readonly clientId: string; /** Active Presentation agreements projected into this invocation. */ readonly contracts: readonly ProtocolSupport[]; } interface PresentationRequestContext { readonly requestId: string; readonly invocationId: string; readonly origin: string; readonly deadline?: string; } /** Invocation authority supplied by the Host when it creates scoped clients. */ interface PresentationInvocationScope { readonly invocationId: string; readonly origin: string; readonly deadline?: string; nextRequestId(): string; } type PresentationResult = { readonly status: 'submitted'; readonly value: T; } | { readonly status: 'cancelled'; } | { readonly status: 'expired'; } | { readonly status: 'unavailable'; readonly reason?: string; }; interface OpenExternalRequest extends PresentationRequestContext { readonly uri: string; } type OpenExternalInput = Omit; interface OpenExternalReceipt { readonly accepted: true; } interface CopyTextRequest extends PresentationRequestContext { readonly text: string; readonly sensitivity?: 'public' | 'private'; } type CopyTextInput = Omit; interface CopyTextReceipt { readonly accepted: true; } interface NotificationRequest extends PresentationRequestContext { readonly text: string; readonly level?: 'info' | 'warning' | 'error'; readonly deduplicationKey?: string; } type NotificationInput = Omit; interface NotificationReceipt { readonly accepted: true; } type UserInteractionOperation = 'question' | 'approval' | 'secret-input'; interface UserInteractionRequirementSpec { readonly operations: readonly UserInteractionOperation[]; readonly optionalOperations?: readonly UserInteractionOperation[]; } interface UserInteractionLimits { readonly maxConcurrentRequests?: number; readonly maxFields?: number; readonly maxOptionsPerField?: number; readonly maxTextLength?: number; } interface UserInteractionSupportSpec { readonly operations: readonly UserInteractionOperation[]; readonly limits?: UserInteractionLimits; } interface QuestionOption { readonly id: string; readonly label: string; readonly description?: string; } interface QuestionFieldBase { readonly id: string; readonly label: string; readonly description?: string; readonly required?: boolean; } interface TextQuestionField extends QuestionFieldBase { readonly kind: 'text'; readonly multiline?: boolean; readonly minLength?: number; readonly maxLength?: number; } interface SelectQuestionField extends QuestionFieldBase { readonly kind: 'select'; readonly multiple?: boolean; readonly options: readonly QuestionOption[]; } interface ConfirmQuestionField extends QuestionFieldBase { readonly kind: 'confirm'; } type QuestionField = TextQuestionField | SelectQuestionField | ConfirmQuestionField; interface QuestionRequest extends PresentationRequestContext { readonly kind: 'question'; readonly title?: string; readonly description?: string; readonly fields: readonly QuestionField[]; } interface QuestionAnswers { readonly answers: Readonly>; } interface ApprovalDetail { readonly label: string; readonly value: string; readonly sensitivity?: 'public' | 'private'; } interface ApprovalRequest extends PresentationRequestContext { readonly kind: 'approval'; readonly action: string; readonly summary: string; readonly details?: readonly ApprovalDetail[]; readonly risk?: 'low' | 'medium' | 'high'; } interface ApprovalValue { readonly decision: 'approved' | 'denied'; } interface SecretInputRequest extends PresentationRequestContext { readonly kind: 'secret-input'; readonly label: string; readonly description?: string; readonly minLength?: number; readonly maxLength?: number; } interface SecretInputValue { readonly secret: string; } type UserInteractionRequest = QuestionRequest | ApprovalRequest | SecretInputRequest; type UserInteractionValue = QuestionAnswers | ApprovalValue | SecretInputValue; type QuestionInput = Omit; type ApprovalInput = Omit; type SecretInput = Omit; interface OpenExternalClient { openExternal(input: OpenExternalInput, options?: { readonly signal?: AbortSignal; }): Promise>; } interface CopyTextClient { copyText(input: CopyTextInput, options?: { readonly signal?: AbortSignal; }): Promise>; } interface NotificationClient { notify(input: NotificationInput, options?: { readonly signal?: AbortSignal; }): Promise>; } interface UserInteractionClient { interact(input: QuestionInput, options?: { readonly signal?: AbortSignal; }): Promise>; interact(input: ApprovalInput, options?: { readonly signal?: AbortSignal; }): Promise>; interact(input: SecretInput, options?: { readonly signal?: AbortSignal; }): Promise>; } /** Typed Presentation capabilities available to one domain invocation. */ interface PresentationClients { readonly descriptor: PresentationDescriptor; readonly openExternal?: OpenExternalClient; readonly copyText?: CopyTextClient; readonly notification?: NotificationClient; readonly interaction?: UserInteractionClient; readonly externalRedirect?: ExternalRedirectClient; } interface OpenExternalHandler { openExternal(request: OpenExternalRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; } interface CopyTextHandler { copyText(request: CopyTextRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; } interface NotificationHandler { notify(request: NotificationRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; } interface UserInteractionHandler { interact(request: QuestionRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; interact(request: ApprovalRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; interact(request: SecretInputRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; } declare const openExternalProtocol: ProtocolDefinition; declare const copyTextProtocol: ProtocolDefinition; declare const notificationProtocol: ProtocolDefinition; declare const openExternalSupport: ProtocolSupport; declare const copyTextSupport: ProtocolSupport; declare const notificationSupport: ProtocolSupport; declare const userInteractionSupport: (spec: UserInteractionSupportSpec) => ProtocolSupport; declare const userInteractionProtocol: ProtocolDefinition; declare const protocols: readonly ProtocolDefinition[]; declare function register(catalog: ProtocolCatalog): () => void; declare function openExternalClient(client: CapabilityClient, scope: PresentationInvocationScope): OpenExternalClient; declare function copyTextClient(client: CapabilityClient, scope: PresentationInvocationScope): CopyTextClient; declare function notificationClient(client: CapabilityClient, scope: PresentationInvocationScope): NotificationClient; declare function userInteractionClient(client: CapabilityClient, scope: PresentationInvocationScope): UserInteractionClient; declare function presentationClients(descriptor: PresentationDescriptor, client: CapabilityClient, scope: PresentationInvocationScope): PresentationClients; declare function openExternalImplementation(participantId: string, handler: OpenExternalHandler): CapabilityImplementation; declare function copyTextImplementation(participantId: string, handler: CopyTextHandler): CapabilityImplementation; declare function notificationImplementation(participantId: string, handler: NotificationHandler): CapabilityImplementation; declare function userInteractionImplementation(participantId: string, spec: UserInteractionSupportSpec, handler: UserInteractionHandler): CapabilityImplementation; declare function validatePresentationDescriptor(value: unknown): asserts value is PresentationDescriptor; declare function validateOpenExternalRequest(value: unknown): asserts value is OpenExternalRequest; declare function validateCopyTextRequest(value: unknown): asserts value is CopyTextRequest; declare function validateNotificationRequest(value: unknown): asserts value is NotificationRequest; declare function validateUserInteractionRequest(value: unknown): asserts value is UserInteractionRequest; declare function validateUserInteractionRequirement(value: unknown): UserInteractionRequirementSpec; declare function validateUserInteractionSupport(value: unknown): UserInteractionSupportSpec; //#endregion //#region src/callback.d.ts declare const EXTERNAL_REDIRECT_KIND = "ExternalRedirect"; interface ExternalRedirectRequest extends PresentationRequestContext { readonly mode: 'http-get'; /** Exact loopback URI required by the external provider, including an explicit port. */ readonly exactRedirectUri?: string; } interface ExternalRedirectInput { readonly mode?: 'http-get'; /** The provider must bind and announce this exact URI or report the request unavailable. */ readonly exactRedirectUri?: string; } interface ExternalRedirectReady { readonly type: 'ready'; readonly redirectUri: string; readonly expiresAt?: string; } interface ExternalRedirectValue { readonly query: Readonly>; } interface ExternalRedirectCall { readonly invocationId: string; readonly ready: Promise; readonly result: Promise>; cancel(reason?: string): void; } interface ExternalRedirectClient { receive(input?: ExternalRedirectInput, options?: { readonly signal?: AbortSignal; }): ExternalRedirectCall; } interface ExternalRedirectHandler { receive(request: ExternalRedirectRequest, context: CapabilityHandlerContext): PresentationResult | Promise>; } declare const externalRedirectProtocol: import("@dsh-std/core").ProtocolDefinition; declare const externalRedirectSupport: ProtocolSupport; declare function externalRedirectClient(client: CapabilityClient, scope: PresentationInvocationScope): ExternalRedirectClient; declare function externalRedirectImplementation(participantId: string, handler: ExternalRedirectHandler): CapabilityImplementation, ExternalRedirectReady>; declare function validateExternalRedirectRequest(value: unknown): asserts value is ExternalRedirectRequest; declare function validateExternalRedirectReady(value: unknown): asserts value is ExternalRedirectReady; declare function validateExternalRedirectResult(value: unknown): PresentationResult; //#endregion export { API_VERSION, ApprovalDetail, ApprovalInput, ApprovalRequest, ApprovalValue, COPY_TEXT_KIND, ConfirmQuestionField, CopyTextClient, CopyTextHandler, CopyTextInput, CopyTextReceipt, CopyTextRequest, EXTERNAL_REDIRECT_KIND, ExternalRedirectCall, ExternalRedirectClient, ExternalRedirectHandler, ExternalRedirectInput, ExternalRedirectReady, ExternalRedirectRequest, ExternalRedirectValue, NOTIFICATION_KIND, NotificationClient, NotificationHandler, NotificationInput, NotificationReceipt, NotificationRequest, OPEN_EXTERNAL_KIND, OpenExternalClient, OpenExternalHandler, OpenExternalInput, OpenExternalReceipt, OpenExternalRequest, PresentationClients, PresentationDescriptor, PresentationInvocationScope, PresentationRequestContext, PresentationResult, QuestionAnswers, QuestionField, QuestionInput, QuestionOption, QuestionRequest, SecretInput, SecretInputRequest, SecretInputValue, SelectQuestionField, TextQuestionField, USER_INTERACTION_KIND, UserInteractionClient, UserInteractionHandler, UserInteractionLimits, UserInteractionOperation, UserInteractionRequest, UserInteractionRequirementSpec, UserInteractionSupportSpec, UserInteractionValue, copyTextClient, copyTextImplementation, copyTextProtocol, copyTextSupport, externalRedirectClient, externalRedirectImplementation, externalRedirectProtocol, externalRedirectSupport, notificationClient, notificationImplementation, notificationProtocol, notificationSupport, openExternalClient, openExternalImplementation, openExternalProtocol, openExternalSupport, presentationClients, protocols, register, userInteractionClient, userInteractionImplementation, userInteractionProtocol, userInteractionSupport, validateCopyTextRequest, validateExternalRedirectReady, validateExternalRedirectRequest, validateExternalRedirectResult, validateNotificationRequest, validateOpenExternalRequest, validatePresentationDescriptor, validateUserInteractionRequest, validateUserInteractionRequirement, validateUserInteractionSupport }; //# sourceMappingURL=index.d.ts.map