Skip to content

Commit

Permalink
fix: inconsistent w3ui custom URL handling
Browse files Browse the repository at this point in the history
this is one way of resolving issue storacha#344, where a custom server URL is used only for the individual HTTP requests and not for the corresponding WebSocket connection
  • Loading branch information
natevw committed Jan 31, 2023
1 parent fc53a16 commit bcbc8f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/access-client/src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class Agent {
* @param {import('./types').AgentOptions} [options]
*/
constructor(data, options = {}) {
this.url = options.url ?? new URL(HOST)
this.url = options.connection?.url ?? options.url ?? new URL(HOST)
this.connection =
options.connection ??
connection({
Expand Down
7 changes: 6 additions & 1 deletion packages/access-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ export interface SpaceMeta {
* Agent class types
*/

// w3ui's keyring providers pass custom URL via this object
interface _AgentConnection extends ConnectionView<Service> {
url?: URL
}

export interface AgentOptions {
url?: URL
connection?: ConnectionView<Service>
connection?: _AgentConnection
servicePrincipal?: Principal
}

Expand Down

0 comments on commit bcbc8f8

Please # to comment.