@verentis/sdk 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -81,6 +81,51 @@ interface VerentisBackendCredentialResponse extends VerentisMessage {
81
81
  credential?: AppBackendCredential;
82
82
  error?: string;
83
83
  }
84
+ /** Nonsecret active-document metadata. CODE already holds its own scoped credential. */
85
+ interface WopiContinuation {
86
+ sessionId: string;
87
+ workspaceId: string;
88
+ branch: string;
89
+ nodeId: string;
90
+ accessTokenTtl: number;
91
+ fileId: string;
92
+ format: string;
93
+ readOnly: boolean;
94
+ name: string;
95
+ }
96
+ /** Initial document-scoped collaboration authority, never a platform OAuth credential. */
97
+ interface WopiLaunch extends WopiContinuation {
98
+ action: string;
99
+ accessToken: string;
100
+ editorOrigin: string;
101
+ wopiSource: string;
102
+ }
103
+ interface WopiSaveCheckpoint {
104
+ generation: number;
105
+ correlation: string;
106
+ revision?: string | null;
107
+ }
108
+ interface WopiSaveStatus {
109
+ state: string;
110
+ revision: string;
111
+ readOnly: boolean;
112
+ receipt: WopiSaveCheckpoint | null;
113
+ continuationAvailable?: boolean;
114
+ }
115
+ interface VerentisWopiRequest extends VerentisMessage {
116
+ type: 'verentis:wopi:request';
117
+ requestId: string;
118
+ sessionId: string;
119
+ operation: 'launch' | 'status' | 'save' | 'close' | 'continue';
120
+ generation?: number;
121
+ }
122
+ interface VerentisWopiResponse extends VerentisMessage {
123
+ type: 'verentis:wopi:response';
124
+ requestId: string;
125
+ sessionId: string;
126
+ result?: WopiLaunch | WopiContinuation | WopiSaveCheckpoint | WopiSaveStatus | null;
127
+ error?: string;
128
+ }
84
129
  interface VerentisFileChangedMessage extends VerentisMessage {
85
130
  type: 'verentis:file:changed';
86
131
  path: string;
@@ -118,8 +163,8 @@ interface VerentisDirtyMessage extends VerentisMessage {
118
163
  type: 'verentis:dirty';
119
164
  isDirty: boolean;
120
165
  }
121
- type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage | VerentisBackendCredentialResponse;
122
- type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage | VerentisBackendCredentialRequest;
166
+ type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage | VerentisBackendCredentialResponse | VerentisWopiResponse;
167
+ type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage | VerentisBackendCredentialRequest | VerentisWopiRequest;
123
168
  type AppSurface = 'file' | 'workspace';
124
169
  interface AppContextBase {
125
170
  workspace: WorkspaceInfo;
@@ -127,8 +172,9 @@ interface AppContextBase {
127
172
  apiUrl: string;
128
173
  installation?: {
129
174
  id: string;
130
- backendClientId: string;
131
- authorizationGeneration: string;
175
+ backendClientId?: string;
176
+ authorizationGeneration?: string;
177
+ wopiEnabled?: boolean;
132
178
  };
133
179
  }
134
180
  /** Context for an application opened against a workspace file. */
@@ -1033,6 +1079,7 @@ declare class Bridge {
1033
1079
  private actions;
1034
1080
  private requests;
1035
1081
  private backendRequests;
1082
+ private wopiRequests;
1036
1083
  constructor(expectedHostOrigin?: string | undefined);
1037
1084
  /** Post `verentis:ready` to the host to start the handshake */
1038
1085
  sendReady(capabilities?: string[]): void;
@@ -1063,6 +1110,14 @@ declare class Bridge {
1063
1110
  setDirty(isDirty: boolean): void;
1064
1111
  /** The host, not the app, selects the installation, file, branch and permission ceiling. */
1065
1112
  requestBackendCredential(): Promise<AppBackendCredential>;
1113
+ /** The trusted parent selects the approved installation, document and action. */
1114
+ requestWopiLaunch(): Promise<WopiLaunch>;
1115
+ /** Recover only the target selected by a completed server-owned derived operation. */
1116
+ requestWopiContinuation(): Promise<WopiContinuation>;
1117
+ getWopiStatus(): Promise<WopiSaveStatus>;
1118
+ requestWopiSave(generation: number): Promise<WopiSaveCheckpoint>;
1119
+ closeWopiSession(): Promise<void>;
1120
+ private requestWopi;
1066
1121
  registerAction(descriptor: HeaderAction, handler: HeaderActionHandler): HeaderActionRegistration;
1067
1122
  private publishActions;
1068
1123
  private invokeAction;
@@ -1202,4 +1257,4 @@ declare class BridgeAuth implements AuthStrategy {
1202
1257
  */
1203
1258
  declare function createVerentisClient(options?: VerentisClientOptions): VerentisClient;
1204
1259
 
1205
- export { ApiError, ApiKeyAuth, type AppBackendCredential, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, type VerentisBackendCredentialRequest, type VerentisBackendCredentialResponse, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
1260
+ export { ApiError, ApiKeyAuth, type AppBackendCredential, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, type VerentisBackendCredentialRequest, type VerentisBackendCredentialResponse, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type VerentisWopiRequest, type VerentisWopiResponse, type WaitOptions, type WopiContinuation, type WopiLaunch, type WopiSaveCheckpoint, type WopiSaveStatus, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
package/dist/index.d.ts CHANGED
@@ -81,6 +81,51 @@ interface VerentisBackendCredentialResponse extends VerentisMessage {
81
81
  credential?: AppBackendCredential;
82
82
  error?: string;
83
83
  }
84
+ /** Nonsecret active-document metadata. CODE already holds its own scoped credential. */
85
+ interface WopiContinuation {
86
+ sessionId: string;
87
+ workspaceId: string;
88
+ branch: string;
89
+ nodeId: string;
90
+ accessTokenTtl: number;
91
+ fileId: string;
92
+ format: string;
93
+ readOnly: boolean;
94
+ name: string;
95
+ }
96
+ /** Initial document-scoped collaboration authority, never a platform OAuth credential. */
97
+ interface WopiLaunch extends WopiContinuation {
98
+ action: string;
99
+ accessToken: string;
100
+ editorOrigin: string;
101
+ wopiSource: string;
102
+ }
103
+ interface WopiSaveCheckpoint {
104
+ generation: number;
105
+ correlation: string;
106
+ revision?: string | null;
107
+ }
108
+ interface WopiSaveStatus {
109
+ state: string;
110
+ revision: string;
111
+ readOnly: boolean;
112
+ receipt: WopiSaveCheckpoint | null;
113
+ continuationAvailable?: boolean;
114
+ }
115
+ interface VerentisWopiRequest extends VerentisMessage {
116
+ type: 'verentis:wopi:request';
117
+ requestId: string;
118
+ sessionId: string;
119
+ operation: 'launch' | 'status' | 'save' | 'close' | 'continue';
120
+ generation?: number;
121
+ }
122
+ interface VerentisWopiResponse extends VerentisMessage {
123
+ type: 'verentis:wopi:response';
124
+ requestId: string;
125
+ sessionId: string;
126
+ result?: WopiLaunch | WopiContinuation | WopiSaveCheckpoint | WopiSaveStatus | null;
127
+ error?: string;
128
+ }
84
129
  interface VerentisFileChangedMessage extends VerentisMessage {
85
130
  type: 'verentis:file:changed';
86
131
  path: string;
@@ -118,8 +163,8 @@ interface VerentisDirtyMessage extends VerentisMessage {
118
163
  type: 'verentis:dirty';
119
164
  isDirty: boolean;
120
165
  }
121
- type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage | VerentisBackendCredentialResponse;
122
- type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage | VerentisBackendCredentialRequest;
166
+ type HostToAppMessage = VerentisInitMessage | VerentisActionInvokeMessage | VerentisTokenRefreshedMessage | VerentisFileChangedMessage | VerentisThemeMessage | VerentisBackendCredentialResponse | VerentisWopiResponse;
167
+ type AppToHostMessage = VerentisReadyMessage | VerentisActionsSetMessage | VerentisActionResultMessage | VerentisTokenRefreshMessage | VerentisNavigateMessage | VerentisResizeMessage | VerentisTitleMessage | VerentisDirtyMessage | VerentisBackendCredentialRequest | VerentisWopiRequest;
123
168
  type AppSurface = 'file' | 'workspace';
124
169
  interface AppContextBase {
125
170
  workspace: WorkspaceInfo;
@@ -127,8 +172,9 @@ interface AppContextBase {
127
172
  apiUrl: string;
128
173
  installation?: {
129
174
  id: string;
130
- backendClientId: string;
131
- authorizationGeneration: string;
175
+ backendClientId?: string;
176
+ authorizationGeneration?: string;
177
+ wopiEnabled?: boolean;
132
178
  };
133
179
  }
134
180
  /** Context for an application opened against a workspace file. */
@@ -1033,6 +1079,7 @@ declare class Bridge {
1033
1079
  private actions;
1034
1080
  private requests;
1035
1081
  private backendRequests;
1082
+ private wopiRequests;
1036
1083
  constructor(expectedHostOrigin?: string | undefined);
1037
1084
  /** Post `verentis:ready` to the host to start the handshake */
1038
1085
  sendReady(capabilities?: string[]): void;
@@ -1063,6 +1110,14 @@ declare class Bridge {
1063
1110
  setDirty(isDirty: boolean): void;
1064
1111
  /** The host, not the app, selects the installation, file, branch and permission ceiling. */
1065
1112
  requestBackendCredential(): Promise<AppBackendCredential>;
1113
+ /** The trusted parent selects the approved installation, document and action. */
1114
+ requestWopiLaunch(): Promise<WopiLaunch>;
1115
+ /** Recover only the target selected by a completed server-owned derived operation. */
1116
+ requestWopiContinuation(): Promise<WopiContinuation>;
1117
+ getWopiStatus(): Promise<WopiSaveStatus>;
1118
+ requestWopiSave(generation: number): Promise<WopiSaveCheckpoint>;
1119
+ closeWopiSession(): Promise<void>;
1120
+ private requestWopi;
1066
1121
  registerAction(descriptor: HeaderAction, handler: HeaderActionHandler): HeaderActionRegistration;
1067
1122
  private publishActions;
1068
1123
  private invokeAction;
@@ -1202,4 +1257,4 @@ declare class BridgeAuth implements AuthStrategy {
1202
1257
  */
1203
1258
  declare function createVerentisClient(options?: VerentisClientOptions): VerentisClient;
1204
1259
 
1205
- export { ApiError, ApiKeyAuth, type AppBackendCredential, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, type VerentisBackendCredentialRequest, type VerentisBackendCredentialResponse, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type WaitOptions, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
1260
+ export { ApiError, ApiKeyAuth, type AppBackendCredential, type AppContext, type AppSurface, type AppToHostMessage, type ApplicationDisplayOptions, type ApplicationEntryPoint, type ApplicationFileType, type ApplicationLaunchConfig, type ApplicationManifest, type ApplicationSpec, type ArchiveFormat, type AuthOptions, type AuthStrategy, Bridge, BridgeAuth, type CatalogImage, ContextModule, type DeleteFileOptions, type EngineFileType, type EngineRuntime, type EngineTool, EnginesModule, type EntryPointInfo, type ExecuteEngineOptions, type Execution, type ExecutionEngine, type ExecutionEngineListOptions, type ExecutionListOptions, type ExecutionLogs, type ExecutionMode, type ExecutionResult, type ExecutionScopedOptions, type ExecutionStatus, type ExecutionTrigger, ExecutionsModule, type ExtractUploadOptions, type FileAppContext, type FileEntry, type FileInfo, FilesModule, type GetFileOptions, type HeaderAction, type HeaderActionHandler, type HeaderActionRegistration, type HeaderActionResult, type HostToAppMessage, HttpTransport, type Installation, type InstallationDetail, type InstallationLifecycleResult, type InstallationListOptions, type InstallationMode, type InstallationScopedOptions, type InstallationStatus, InstallationsModule, type InstalledPackageDescriptor, type InstalledPackagePayload, type ManifestMetadata, type MimeTypeBinding, type MoveFileOptions, type NamespacedSettings, type NavigateOptions, type OAuthConfig, type PagedResult, type ReadArchiveOptions, type RequestOptions, type ResolveInstallationOptions, type ResourceMimeTypeBinding, type ResourceRegistration, type ResourceScopedOptions, ResourcesModule, type RunFileOptions, type SandboxOptions, type SettingDeclaration, type SettingDeclarationType, type SettingGroup, type SettingItem, type SettingOption, type SettingPresence, SettingsModule, type SettingsScopedOptions, TokenAuth, type TokenInfo, type UpdateInstallationOptions, type VerentisActionInvokeMessage, type VerentisActionResultMessage, type VerentisActionsSetMessage, type VerentisBackendCredentialRequest, type VerentisBackendCredentialResponse, VerentisClient, type VerentisClientOptions, type VerentisDirtyMessage, type VerentisFileChangedMessage, type VerentisInitMessage, type VerentisMessage, type VerentisNavigateMessage, type VerentisReadyMessage, type VerentisResizeMessage, type VerentisThemeMessage, type VerentisTitleMessage, type VerentisTokenRefreshMessage, type VerentisTokenRefreshedMessage, type VerentisWopiRequest, type VerentisWopiResponse, type WaitOptions, type WopiContinuation, type WopiLaunch, type WopiSaveCheckpoint, type WopiSaveStatus, type WorkspaceAppContext, type WorkspaceInfo, type WriteFileOptions, createVerentisClient, findBestMatch, isHeaderAction, isTerminalStatus, matchMimeType };
package/dist/index.js CHANGED
@@ -807,6 +807,7 @@ var Bridge = class {
807
807
  actions = /* @__PURE__ */ new Map();
808
808
  requests = /* @__PURE__ */ new Set();
809
809
  backendRequests = /* @__PURE__ */ new Map();
810
+ wopiRequests = /* @__PURE__ */ new Map();
810
811
  /** Post `verentis:ready` to the host to start the handshake */
811
812
  sendReady(capabilities) {
812
813
  console.info("[Verentis SDK] Sending verentis:ready to host");
@@ -815,7 +816,7 @@ var Bridge = class {
815
816
  version: 1,
816
817
  capabilities
817
818
  };
818
- window.parent.postMessage(message, "*");
819
+ window.parent.postMessage(message, this.expectedHostOrigin ?? "*");
819
820
  }
820
821
  /** Wait for the host to send `verentis:init` with context and token */
821
822
  waitForInit() {
@@ -890,6 +891,53 @@ var Bridge = class {
890
891
  }
891
892
  });
892
893
  }
894
+ /** The trusted parent selects the approved installation, document and action. */
895
+ requestWopiLaunch() {
896
+ return this.requestWopi("launch");
897
+ }
898
+ /** Recover only the target selected by a completed server-owned derived operation. */
899
+ requestWopiContinuation() {
900
+ return this.requestWopi("continue");
901
+ }
902
+ getWopiStatus() {
903
+ return this.requestWopi("status");
904
+ }
905
+ requestWopiSave(generation) {
906
+ if (!Number.isSafeInteger(generation) || generation < 0)
907
+ return Promise.reject(new Error("Invalid edit generation."));
908
+ return this.requestWopi("save", generation);
909
+ }
910
+ closeWopiSession() {
911
+ return this.requestWopi("close");
912
+ }
913
+ requestWopi(operation, generation) {
914
+ if (this._destroyed || !this.sessionId || !this._hostOrigin)
915
+ return Promise.reject(new Error("An initialized workspace host is required."));
916
+ if (this.wopiRequests.size >= 4)
917
+ return Promise.reject(new Error("Too many collaboration requests."));
918
+ const requestId = crypto.randomUUID();
919
+ return new Promise((resolve, reject) => {
920
+ const timer = setTimeout(() => {
921
+ this.wopiRequests.delete(requestId);
922
+ reject(new Error("Collaboration authorization timed out."));
923
+ }, 3e4);
924
+ this.wopiRequests.set(requestId, { resolve, reject, timer });
925
+ try {
926
+ this.postToHost({
927
+ type: "verentis:wopi:request",
928
+ version: 1,
929
+ requestId,
930
+ sessionId: this.sessionId,
931
+ operation,
932
+ ...generation === void 0 ? {} : { generation }
933
+ });
934
+ } catch {
935
+ clearTimeout(timer);
936
+ this.wopiRequests.delete(requestId);
937
+ reject(new Error("The workspace host is unavailable."));
938
+ }
939
+ });
940
+ }
893
941
  registerAction(descriptor, handler) {
894
942
  if (!this.sessionId || this._destroyed) throw new Error("Header actions require an initialized workspace host.");
895
943
  if (!isHeaderAction(descriptor)) throw new Error("Invalid header action.");
@@ -977,6 +1025,11 @@ var Bridge = class {
977
1025
  pending.reject(new Error("Bridge has been destroyed."));
978
1026
  }
979
1027
  this.backendRequests.clear();
1028
+ for (const pending of this.wopiRequests.values()) {
1029
+ clearTimeout(pending.timer);
1030
+ pending.reject(new Error("Bridge has been destroyed."));
1031
+ }
1032
+ this.wopiRequests.clear();
980
1033
  if (typeof window !== "undefined") {
981
1034
  window.removeEventListener("message", this._messageHandler);
982
1035
  }
@@ -1014,6 +1067,17 @@ var Bridge = class {
1014
1067
  else pending.resolve(value);
1015
1068
  return;
1016
1069
  }
1070
+ if (data.type === "verentis:wopi:response") {
1071
+ if (!this._hostOrigin || data.sessionId !== this.sessionId) return;
1072
+ const pending = this.wopiRequests.get(data.requestId);
1073
+ if (!pending) return;
1074
+ clearTimeout(pending.timer);
1075
+ this.wopiRequests.delete(data.requestId);
1076
+ if (data.error || !Object.hasOwn(data, "result"))
1077
+ pending.reject(new Error("Collaboration authorization is unavailable."));
1078
+ else pending.resolve(data.result);
1079
+ return;
1080
+ }
1017
1081
  if (data.type === "verentis:action:invoke") {
1018
1082
  void this.invokeAction(data);
1019
1083
  return;