Skip to main content

FrameClient

Constructor

new FrameClient({
  target,
  timeout
})

FrameClient is a client that looks to the user like an ElvClient, but works by passing messages to another frame with an actual ElvClient instead of making the calls itself.

The purpose of this is to isolate users' private keys and the usage thereof in one trusted application, while still allowing other (possibly less trustworthy) applications to communicate with the content fabric on behalf of the user from a sandboxed IFrame.

FrameClient has available almost all of the same methods as ElvClient, and should be transparently interchangable with it from a usage perspective.

The methods available in FrameClient are generated automatically from ElvClient. These methods will use a messaging protocol to communicate intent to a specified frame, which can listen for such messages, perform the actions using the real ElvClient, and return the results via a response message.

Because the privileged frame is doing the actual work, it may decide to allow or disallow any actions it sees fit - for example, limiting a dependent app to a few safe calls while preventing it from making any significant changes.

The most important aspect of this architecture is to prevent leaking of users' private keys. Be careful when setting up a project using this architecture - make sure the untrusted app is properly contained in a sandboxed IFrame and served from a different origin than the privileged app.

Parameters

NameTypeRequiredDescription
targetObject

The window or frame that will listen for messages produced by this client

timeoutnumber

How long to wait for a response after calling a method before giving up and generating a timeout error

AllowedMethods

AllowedMethods() → Array.<string>

Returns: List of ElvClient methods available to a FrameClient

PassRequest

PassRequest({ request }) → object

Pass an ElvFrameRequest to the target and receive a ElvFrameResponse. Useful when acting as an intermediate between a contained app and a parent app.

Returns: The resultant ElvFrameResponse

Parameters

NameTypeRequiredDescription
requestobject

An ElvFrameRequest