Skip to main content

WebRemote

Extends

Constructors

new WebRemote()

new WebRemote(
connector,
logger,
options?): WebRemote

Parameters

ParameterTypeDefault value
connectorRemoteConnectorundefined
loggerILoggerDEFAULT_REMOTE_LOGGER
options?Partial<AbstractRemoteOptions>undefined

Returns

WebRemote

Overrides

AbstractRemote.constructor

Accessors

fetch

Get Signature

get fetch(): (input, init?) => Promise<Response>(input, init?) => Promise<Response>(input, init?) => Promise<Response>
Returns

Function

a fetch implementation (function) which can be called to perform fetch requests

MDN Reference

Parameters
ParameterType
inputURL | RequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputURL | RequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputstring | URL | Request
init?RequestInit
Returns

Promise<Response>

Inherited from

AbstractRemote.fetch

Methods

createTextDecoder()

createTextDecoder(): TextDecoder

Returns

TextDecoder

A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the builtin, without forcing us to bundle a polyfill with @powersync/common.

Inherited from

AbstractRemote.createTextDecoder


fetchCredentials()

fetchCredentials(): Promise<null | PowerSyncCredentials>

Get credentials for PowerSync.

This should always fetch a fresh set of credentials - don't use cached values.

Returns

Promise<null | PowerSyncCredentials>

Inherited from

AbstractRemote.fetchCredentials


fetchStream()

fetchStream(options): Promise<SimpleAsyncIterator<string | Uint8Array<ArrayBufferLike>>>

Posts a /sync/stream request.

Depending on the Content-Type of the response, this returns strings for sync lines or encoded BSON documents as Uint8Arrays.

Parameters

ParameterType
optionsSyncStreamOptions

Returns

Promise<SimpleAsyncIterator<string | Uint8Array<ArrayBufferLike>>>

Inherited from

AbstractRemote.fetchStream


get()

get(path, headers?): Promise<any>

Parameters

ParameterType
pathstring
headers?Record<string, string>

Returns

Promise<any>

Inherited from

AbstractRemote.get


getBSON()

getBSON(): Promise<typeof BSON>

Provides a BSON implementation. The import nature of this varies depending on the platform

Returns

Promise<typeof BSON>

Overrides

AbstractRemote.getBSON


getCredentials()

getCredentials(): Promise<null | PowerSyncCredentials>

Get credentials currently cached, or fetch new credentials if none are available.

These credentials may have expired already.

Returns

Promise<null | PowerSyncCredentials>

Inherited from

AbstractRemote.getCredentials


getUserAgent()

getUserAgent(): string

Returns

string

Overrides

AbstractRemote.getUserAgent


invalidateCredentials()

invalidateCredentials(): void

Immediately invalidate credentials.

This may be called when the current credentials have expired.

Returns

void

Inherited from

AbstractRemote.invalidateCredentials


post()

post(
path,
data,
headers?): Promise<any>

Parameters

ParameterType
pathstring
dataany
headers?Record<string, string>

Returns

Promise<any>

Inherited from

AbstractRemote.post


prefetchCredentials()

prefetchCredentials(): Promise<null | PowerSyncCredentials>

Fetch a new set of credentials and cache it.

Until this call succeeds, getCredentials will still return the old credentials.

This may be called before the current credentials have expired.

Returns

Promise<null | PowerSyncCredentials>

Inherited from

AbstractRemote.prefetchCredentials


socketStreamRaw()

socketStreamRaw(options, bson?): Promise<SimpleAsyncIterator<Uint8Array<ArrayBufferLike>>>

Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.

The only mechanism to abort the returned stream is to use the abort signal in SocketSyncStreamOptions.

Parameters

ParameterTypeDescription
optionsSocketSyncStreamOptions-
bson?typeof BSONA BSON encoder and decoder. When set, the data stream will be requested with a BSON payload (required for compatibility with older sync services).

Returns

Promise<SimpleAsyncIterator<Uint8Array<ArrayBufferLike>>>

Inherited from

AbstractRemote.socketStreamRaw