-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
504 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface Connectable { | ||
|
||
connect(): Promise<void> | ||
|
||
disconnect(): Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import { Channel, ContextHandler, Listener, PrivateChannel } from "@finos/fdc3" | ||
import { ContextElement } from "@finos/fdc3/dist/bridging/BridgingTypes" | ||
|
||
export interface ChannelSupport { | ||
|
||
hasUserChannelMembershipAPIs(): boolean | ||
|
||
getUserChannel() : Promise<Channel | null> | ||
getUserChannel(): Promise<Channel | null> | ||
|
||
getUserChannels() : Promise<Channel[]> | ||
getUserChannels(): Promise<Channel[]> | ||
|
||
getOrCreate(id: string) : Promise<Channel> | ||
getOrCreate(id: string): Promise<Channel> | ||
|
||
createPrivateChannel() : Promise<PrivateChannel> | ||
createPrivateChannel(): Promise<PrivateChannel> | ||
|
||
leaveUserChannel() : Promise<void> | ||
leaveUserChannel(): Promise<void> | ||
|
||
joinUserChannel(id: string) : Promise<void> | ||
joinUserChannel(id: string): Promise<void> | ||
|
||
addContextListener(handler: ContextHandler, type: string | null) : Promise<Listener> | ||
addContextListener(handler: ContextHandler, type: string | null): Promise<Listener> | ||
|
||
mergeChannelState(newState: { [key: string]: ContextElement[] }): void | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/da-proxy/src/handshake/DefaultHandshakeSupport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ConnectionStep2Hello, ConnectionStep3Handshake, ConnectionStep3HandshakePayload } from "@finos/fdc3/dist/bridging/BridgingTypes"; | ||
import { Messaging } from "../Messaging"; | ||
import { ChannelSupport } from "../channels/ChannelSupport"; | ||
import { HandshakeSupport } from "./HandshakeSupport"; | ||
|
||
/** | ||
* This will eventually need extending to allow for auth handshaking. | ||
*/ | ||
export class DefaultHandshakeSupport implements HandshakeSupport { | ||
|
||
readonly messaging: Messaging | ||
readonly acceptableFDC3Versions: string[] | ||
readonly channels: ChannelSupport | ||
private handshakePayload: ConnectionStep3HandshakePayload | null = null | ||
|
||
constructor(messaging: Messaging, acceptableFDC3Versions: string[], cs: ChannelSupport) { | ||
this.messaging = messaging | ||
this.acceptableFDC3Versions = acceptableFDC3Versions | ||
this.channels = cs | ||
} | ||
|
||
async connect(): Promise<void> { | ||
const hello: ConnectionStep2Hello = { | ||
type: "hello", | ||
payload: { | ||
desktopAgentBridgeVersion: "1.0", | ||
supportedFDC3Versions: this.acceptableFDC3Versions, | ||
authRequired: false, | ||
}, | ||
meta: { | ||
timestamp: new Date() | ||
} | ||
} | ||
|
||
const handshake = await this.messaging.exchange<ConnectionStep3Handshake>(hello, "handshake") | ||
this.channels.mergeChannelState(handshake.payload.channelsState) | ||
this.handshakePayload = handshake.payload | ||
return Promise.resolve() | ||
} | ||
|
||
disconnect(): Promise<void> { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
getHandshakePayload(): ConnectionStep3HandshakePayload | null { | ||
return this.handshakePayload | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ConnectionStep3HandshakePayload } from "@finos/fdc3/dist/bridging/BridgingTypes" | ||
import { Connectable } from "../Connectable" | ||
|
||
/** | ||
* Handles messaging around connection and disconnection of the proxy | ||
* to the server. | ||
*/ | ||
export interface HandshakeSupport extends Connectable { | ||
|
||
getHandshakePayload(): ConnectionStep3HandshakePayload | null | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.