@dxos/edge-client 0.8.3 → 0.8.4-main.1068cf700f

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.
Files changed (66) hide show
  1. package/dist/lib/{browser/chunk-VHS3XEIX.mjs → neutral/chunk-VESGVCLQ.mjs} +15 -11
  2. package/dist/lib/{browser/chunk-VHS3XEIX.mjs.map → neutral/chunk-VESGVCLQ.mjs.map} +3 -3
  3. package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs +1 -1
  4. package/dist/lib/{browser → neutral}/index.mjs +694 -354
  5. package/dist/lib/neutral/index.mjs.map +7 -0
  6. package/dist/lib/neutral/meta.json +1 -0
  7. package/dist/lib/{browser → neutral}/testing/index.mjs +61 -16
  8. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  9. package/dist/types/src/edge-client.d.ts +15 -15
  10. package/dist/types/src/edge-client.d.ts.map +1 -1
  11. package/dist/types/src/edge-http-client.d.ts +59 -31
  12. package/dist/types/src/edge-http-client.d.ts.map +1 -1
  13. package/dist/types/src/edge-http-client.test.d.ts +2 -0
  14. package/dist/types/src/edge-http-client.test.d.ts.map +1 -0
  15. package/dist/types/src/edge-ws-connection.d.ts +20 -0
  16. package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
  17. package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
  18. package/dist/types/src/http-client.d.ts +25 -0
  19. package/dist/types/src/http-client.d.ts.map +1 -0
  20. package/dist/types/src/http-client.test.d.ts +2 -0
  21. package/dist/types/src/http-client.test.d.ts.map +1 -0
  22. package/dist/types/src/index.d.ts +4 -3
  23. package/dist/types/src/index.d.ts.map +1 -1
  24. package/dist/types/src/testing/index.d.ts +1 -0
  25. package/dist/types/src/testing/index.d.ts.map +1 -1
  26. package/dist/types/src/testing/test-server.d.ts +9 -0
  27. package/dist/types/src/testing/test-server.d.ts.map +1 -0
  28. package/dist/types/src/testing/test-utils.d.ts +3 -3
  29. package/dist/types/src/testing/test-utils.d.ts.map +1 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +30 -21
  32. package/src/edge-client.test.ts +4 -4
  33. package/src/edge-client.ts +73 -42
  34. package/src/edge-http-client.test.ts +22 -0
  35. package/src/edge-http-client.ts +368 -152
  36. package/src/edge-ws-connection.ts +129 -8
  37. package/src/edge-ws-muxer.ts +1 -1
  38. package/src/http-client.test.ts +58 -0
  39. package/src/http-client.ts +77 -0
  40. package/src/index.ts +4 -3
  41. package/src/testing/index.ts +1 -0
  42. package/src/testing/test-server.ts +45 -0
  43. package/src/testing/test-utils.ts +9 -9
  44. package/src/websocket.test.ts +1 -1
  45. package/dist/lib/browser/index.mjs.map +0 -7
  46. package/dist/lib/browser/meta.json +0 -1
  47. package/dist/lib/browser/testing/index.mjs.map +0 -7
  48. package/dist/lib/node/chunk-XNHBUTNB.cjs +0 -317
  49. package/dist/lib/node/chunk-XNHBUTNB.cjs.map +0 -7
  50. package/dist/lib/node/edge-ws-muxer.cjs +0 -33
  51. package/dist/lib/node/edge-ws-muxer.cjs.map +0 -7
  52. package/dist/lib/node/index.cjs +0 -1060
  53. package/dist/lib/node/index.cjs.map +0 -7
  54. package/dist/lib/node/meta.json +0 -1
  55. package/dist/lib/node/testing/index.cjs +0 -169
  56. package/dist/lib/node/testing/index.cjs.map +0 -7
  57. package/dist/lib/node-esm/chunk-HGQUUFIJ.mjs +0 -299
  58. package/dist/lib/node-esm/chunk-HGQUUFIJ.mjs.map +0 -7
  59. package/dist/lib/node-esm/edge-ws-muxer.mjs +0 -12
  60. package/dist/lib/node-esm/edge-ws-muxer.mjs.map +0 -7
  61. package/dist/lib/node-esm/index.mjs +0 -1035
  62. package/dist/lib/node-esm/index.mjs.map +0 -7
  63. package/dist/lib/node-esm/meta.json +0 -1
  64. package/dist/lib/node-esm/testing/index.mjs +0 -141
  65. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  66. /package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs.map +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/index.ts", "../../../src/auth.ts", "../../../src/edge-client.ts", "../../../src/edge-identity.ts", "../../../src/edge-ws-connection.ts", "../../../src/errors.ts", "../../../src/utils.ts", "../../../src/edge-http-client.ts", "../../../src/http-client.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport * from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nexport * from './auth';\nexport * from './defs';\nexport * from './edge-client';\nexport * from './errors';\nexport * from './protocol';\nexport * from './edge-http-client';\nexport * from './edge-identity';\nexport * from './edge-ws-muxer';\nexport * from './http-client';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createCredential, signPresentation } from '@dxos/credentials';\nimport { type Signer } from '@dxos/crypto';\nimport { invariant } from '@dxos/invariant';\nimport { Keyring } from '@dxos/keyring';\nimport { PublicKey } from '@dxos/keys';\nimport { type Chain, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport type { EdgeIdentity } from './edge-identity';\n\n/**\n * Edge identity backed by a device key without a credential chain.\n */\nexport const createDeviceEdgeIdentity = async (signer: Signer, key: PublicKey): Promise<EdgeIdentity> => {\n return {\n identityKey: key.toHex(),\n peerKey: key.toHex(),\n presentCredentials: async ({ challenge }) => {\n return signPresentation({\n presentation: {\n credentials: [\n // Verifier requires at least one credential in the presentation to establish the subject.\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: key,\n subject: key,\n signer,\n }),\n ],\n },\n signer,\n signerKey: key,\n nonce: challenge,\n });\n },\n };\n};\n\n/**\n * Edge identity backed by a chain of credentials.\n */\nexport const createChainEdgeIdentity = async (\n signer: Signer,\n identityKey: PublicKey,\n peerKey: PublicKey,\n chain: Chain | undefined,\n credentials: Credential[],\n): Promise<EdgeIdentity> => {\n const credentialsToSign =\n credentials.length > 0\n ? credentials\n : [\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: identityKey,\n subject: identityKey,\n signer,\n chain,\n signingKey: peerKey,\n }),\n ];\n\n return {\n identityKey: identityKey.toHex(),\n peerKey: peerKey.toHex(),\n presentCredentials: async ({ challenge }) => {\n // TODO: make chain required after device invitation flow update release\n invariant(chain);\n return signPresentation({\n presentation: {\n credentials: credentialsToSign,\n },\n signer,\n nonce: challenge,\n signerKey: peerKey,\n chain,\n });\n },\n };\n};\n\n/**\n * Edge identity backed by a random ephemeral key without HALO.\n */\nexport const createEphemeralEdgeIdentity = async (): Promise<EdgeIdentity> => {\n const keyring = new Keyring();\n const key = await keyring.createKey();\n return createDeviceEdgeIdentity(keyring, key);\n};\n\n/**\n * Creates a HALO chain of credentials to act as an edge identity.\n */\nexport const createTestHaloEdgeIdentity = async (\n signer: Signer,\n identityKey: PublicKey,\n deviceKey: PublicKey,\n): Promise<EdgeIdentity> => {\n const deviceAdmission = await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.AuthorizedDevice',\n deviceKey,\n identityKey,\n },\n issuer: identityKey,\n subject: deviceKey,\n signer,\n });\n return createChainEdgeIdentity(signer, identityKey, deviceKey, { credential: deviceAdmission }, [\n await createCredential({\n assertion: {\n '@type': 'dxos.halo.credentials.Auth',\n },\n issuer: identityKey,\n subject: identityKey,\n signer,\n }),\n ]);\n};\n\nexport const createStubEdgeIdentity = (): EdgeIdentity => {\n const identityKey = PublicKey.random();\n const deviceKey = PublicKey.random();\n return {\n identityKey: identityKey.toHex(),\n peerKey: deviceKey.toHex(),\n presentCredentials: async () => {\n throw new Error('Stub identity does not support authentication.');\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n Event,\n PersistentLifecycle,\n Trigger,\n TriggerState,\n scheduleMicroTask,\n scheduleTaskInterval,\n} from '@dxos/async';\nimport { type Lifecycle, Resource } from '@dxos/context';\nimport { log, logInfo } from '@dxos/log';\nimport { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\nimport { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';\n\nimport { protocol } from './defs';\nimport { type EdgeIdentity, handleAuthChallenge } from './edge-identity';\nimport { EdgeWsConnection } from './edge-ws-connection';\nimport { EdgeConnectionClosedError, EdgeIdentityChangedError } from './errors';\nimport { type Protocol } from './protocol';\nimport { getEdgeUrlWithProtocol } from './utils';\n\nconst DEFAULT_TIMEOUT = 10_000;\n\n// Refresh status every second: rtt, rate counters.\nconst STATUS_REFRESH_INTERVAL = 1000;\n\nexport type MessageListener = (message: Message) => void;\nexport type ReconnectListener = () => void;\n\nexport type MessengerConfig = {\n socketEndpoint: string;\n timeout?: number;\n protocol?: Protocol;\n disableAuth?: boolean;\n};\n\nexport interface EdgeConnection extends Required<Lifecycle> {\n statusChanged: Event<EdgeStatus>;\n get info(): any;\n get identityKey(): string;\n get peerKey(): string;\n get isOpen(): boolean;\n get status(): EdgeStatus;\n setIdentity(identity: EdgeIdentity): void;\n send(message: Message): Promise<void>;\n onMessage(listener: MessageListener): () => void;\n onReconnected(listener: ReconnectListener): () => void;\n}\n\n/**\n * Messenger client for EDGE:\n * - While open, uses PersistentLifecycle to keep an open EdgeWsConnection, reconnecting on failures.\n * - Manages identity and re-create EdgeWsConnection when identity changes.\n * - Dispatches connection state and message notifications.\n */\nexport class EdgeClient extends Resource implements EdgeConnection {\n public readonly statusChanged = new Event<EdgeStatus>();\n\n private readonly _persistentLifecycle = new PersistentLifecycle<EdgeWsConnection>({\n start: async () => this._connect(),\n stop: async (state: EdgeWsConnection) => this._disconnect(state),\n });\n\n private readonly _messageListeners = new Set<MessageListener>();\n private readonly _reconnectListeners = new Set<ReconnectListener>();\n private readonly _baseWsUrl: string;\n private readonly _baseHttpUrl: string;\n private _currentConnection?: EdgeWsConnection = undefined;\n private _ready = new Trigger();\n\n constructor(\n private _identity: EdgeIdentity,\n private readonly _config: MessengerConfig,\n ) {\n super();\n this._baseWsUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, 'ws');\n this._baseHttpUrl = getEdgeUrlWithProtocol(_config.socketEndpoint, 'http');\n }\n\n @logInfo\n public get info() {\n return {\n open: this.isOpen,\n status: this.status,\n identity: this._identity.identityKey,\n device: this._identity.peerKey,\n };\n }\n\n get status(): EdgeStatus {\n return {\n state:\n Boolean(this._currentConnection) && this._ready.state === TriggerState.RESOLVED\n ? EdgeStatus.ConnectionState.CONNECTED\n : EdgeStatus.ConnectionState.NOT_CONNECTED,\n uptime: this._currentConnection?.uptime ?? 0,\n rtt: this._currentConnection?.rtt ?? 0,\n rateBytesUp: this._currentConnection?.uploadRate ?? 0,\n rateBytesDown: this._currentConnection?.downloadRate ?? 0,\n messagesSent: this._currentConnection?.messagesSent ?? 0,\n messagesReceived: this._currentConnection?.messagesReceived ?? 0,\n };\n }\n\n get identityKey() {\n return this._identity.identityKey;\n }\n\n get peerKey() {\n return this._identity.peerKey;\n }\n\n setIdentity(identity: EdgeIdentity) {\n if (identity.identityKey !== this._identity.identityKey || identity.peerKey !== this._identity.peerKey) {\n log('Edge identity changed', { identity, oldIdentity: this._identity });\n this._identity = identity;\n this._closeCurrentConnection(new EdgeIdentityChangedError());\n void this._persistentLifecycle.scheduleRestart();\n }\n }\n\n /**\n * Send message.\n * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.\n */\n public async send(message: Message) {\n if (this._ready.state !== TriggerState.RESOLVED) {\n log('waiting for websocket');\n await this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT });\n }\n\n if (!this._currentConnection) {\n throw new EdgeConnectionClosedError();\n }\n\n if (\n message.source &&\n (message.source.peerKey !== this._identity.peerKey || message.source.identityKey !== this.identityKey)\n ) {\n throw new EdgeIdentityChangedError();\n }\n\n this._currentConnection.send(message);\n }\n\n public onMessage(listener: MessageListener) {\n this._messageListeners.add(listener);\n return () => this._messageListeners.delete(listener);\n }\n\n public onReconnected(listener: () => void) {\n this._reconnectListeners.add(listener);\n if (this._ready.state === TriggerState.RESOLVED) {\n // Microtask so that listener is always called asynchronously, no matter the state of the ready trigger\n // at the moment of registration.\n scheduleMicroTask(this._ctx, () => {\n if (this._reconnectListeners.has(listener)) {\n try {\n listener();\n } catch (error) {\n log.catch(error);\n }\n }\n });\n }\n\n return () => this._reconnectListeners.delete(listener);\n }\n\n /**\n * Open connection to messaging service.\n */\n protected override async _open(): Promise<void> {\n log('opening...', { info: this.info });\n this._persistentLifecycle.open().catch((err) => {\n log.warn('Error while opening connection', { err });\n });\n\n // Notify about status changes (rtt, rate counters).\n scheduleTaskInterval(\n this._ctx,\n async () => {\n if (!this._currentConnection) {\n return;\n }\n this.statusChanged.emit(this.status);\n },\n STATUS_REFRESH_INTERVAL,\n );\n }\n\n /**\n * Close connection and free resources.\n */\n protected override async _close(): Promise<void> {\n log('closing...', { peerKey: this._identity.peerKey });\n this._closeCurrentConnection();\n await this._persistentLifecycle.close();\n }\n\n private async _connect(): Promise<EdgeWsConnection | undefined> {\n if (this._ctx.disposed) {\n return undefined;\n }\n\n const identity = this._identity;\n const path = `/ws/${identity.identityKey}/${identity.peerKey}`;\n const protocolHeader = this._config.disableAuth ? undefined : await this._createAuthHeader(path);\n if (this._identity !== identity) {\n log('identity changed during auth header request');\n return undefined;\n }\n\n const restartRequired = new Trigger();\n const url = new URL(path, this._baseWsUrl);\n log('Opening websocket', { url: url.toString(), protocolHeader });\n const connection = new EdgeWsConnection(\n identity,\n { url, protocolHeader },\n {\n onConnected: () => {\n if (this._isActive(connection)) {\n this._ready.wake();\n this._notifyReconnected();\n } else {\n log.verbose('connected callback ignored, because connection is not active');\n }\n },\n onRestartRequired: () => {\n if (this._isActive(connection)) {\n this._closeCurrentConnection();\n void this._persistentLifecycle.scheduleRestart();\n } else {\n log.verbose('restart requested by inactive connection');\n }\n restartRequired.wake();\n },\n onMessage: (message) => {\n if (this._isActive(connection)) {\n this._notifyMessageReceived(message);\n } else {\n log.verbose('ignored a message on inactive connection', {\n from: message.source,\n type: message.payload?.typeUrl,\n });\n }\n },\n },\n );\n this._currentConnection = connection;\n\n await connection.open();\n // Race with restartRequired so that restart is not blocked by _connect execution.\n // Wait on ready to attempt a reconnect if it times out.\n await Promise.race([this._ready.wait({ timeout: this._config.timeout ?? DEFAULT_TIMEOUT }), restartRequired]);\n return connection;\n }\n\n private async _disconnect(state: EdgeWsConnection): Promise<void> {\n await state.close();\n this.statusChanged.emit(this.status);\n }\n\n private _closeCurrentConnection(error: Error = new EdgeConnectionClosedError()): void {\n this._currentConnection = undefined;\n this._ready.throw(error);\n this._ready.reset();\n this.statusChanged.emit(this.status);\n }\n\n private _notifyReconnected(): void {\n this.statusChanged.emit(this.status);\n for (const listener of this._reconnectListeners) {\n try {\n listener();\n } catch (err) {\n log.error('ws reconnect listener failed', { err });\n }\n }\n }\n\n private _notifyMessageReceived(message: Message): void {\n for (const listener of this._messageListeners) {\n try {\n listener(message);\n } catch (err) {\n log.error('ws incoming message processing failed', { err, payload: protocol.getPayloadType(message) });\n }\n }\n }\n\n private async _createAuthHeader(path: string): Promise<string | undefined> {\n const httpUrl = new URL(path, this._baseHttpUrl);\n httpUrl.protocol = getEdgeUrlWithProtocol(this._baseWsUrl.toString(), 'http');\n const response = await fetch(httpUrl, { method: 'GET' });\n if (response.status === 401) {\n return encodePresentationWsAuthHeader(await handleAuthChallenge(response, this._identity));\n } else {\n log.warn('no auth challenge from edge', { status: response.status, statusText: response.statusText });\n return undefined;\n }\n }\n\n private _isActive = (connection: EdgeWsConnection) => connection === this._currentConnection;\n}\n\nconst encodePresentationWsAuthHeader = (encodedPresentation: Uint8Array): string => {\n // '=' and '/' characters are not allowed in the WebSocket subprotocol header.\n const encodedToken = Buffer.from(encodedPresentation).toString('base64').replace(/=*$/, '').replaceAll('/', '|');\n return `base64url.bearer.authorization.dxos.org.${encodedToken}`;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Presentation } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nexport interface EdgeIdentity {\n peerKey: string;\n identityKey: string;\n /**\n * Returns credential presentation issued by the identity key.\n * Presentation must have the provided challenge.\n * Presentation may include ServiceAccess credentials.\n */\n presentCredentials({ challenge }: { challenge: Uint8Array }): Promise<Presentation>;\n}\n\nexport const handleAuthChallenge = async (failedResponse: Response, identity: EdgeIdentity): Promise<Uint8Array> => {\n invariant(failedResponse.status === 401);\n\n const headerValue = failedResponse.headers.get('Www-Authenticate');\n invariant(headerValue?.startsWith('VerifiablePresentation challenge='));\n\n const challenge = headerValue?.slice('VerifiablePresentation challenge='.length);\n invariant(challenge);\n\n const presentation = await identity.presentCredentials({ challenge: Buffer.from(challenge, 'base64') });\n return schema.getCodecForType('dxos.halo.credentials.Presentation').encode(presentation);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { scheduleTask, scheduleTaskInterval } from '@dxos/async';\nimport { Context, Resource } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log, logInfo } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from './defs';\nimport { type EdgeIdentity } from './edge-identity';\nimport { CLOUDFLARE_MESSAGE_MAX_BYTES, WebSocketMuxer } from './edge-ws-muxer';\nimport { toUint8Array } from './protocol';\n\nconst SIGNAL_KEEPALIVE_INTERVAL = 4_000;\nconst SIGNAL_KEEPALIVE_TIMEOUT = 12_000;\n\nexport type EdgeWsConnectionCallbacks = {\n onConnected: () => void;\n onMessage: (message: Message) => void;\n onRestartRequired: () => void;\n};\n\nexport class EdgeWsConnection extends Resource {\n private _inactivityTimeoutCtx: Context | undefined;\n private _ws: WebSocket | undefined;\n private _wsMuxer: WebSocketMuxer | undefined;\n private _lastReceivedMessageTimestamp = Date.now();\n\n private _openTimestamp: number | undefined;\n\n // Latency tracking.\n private _pingTimestamp: number | undefined;\n private _rtt = 0;\n\n // Rate tracking with sliding window.\n private _uploadRate = 0;\n private _downloadRate = 0;\n private readonly _rateWindow = 10000; // 10 second sliding window.\n private readonly _rateUpdateInterval = 1000; // Update rates every second.\n private _bytesSamples: Array<{ timestamp: number; sent: number; received: number }> = [];\n\n private _messagesSent = 0;\n private _messagesReceived = 0;\n\n constructor(\n private readonly _identity: EdgeIdentity,\n private readonly _connectionInfo: { url: URL; protocolHeader?: string },\n private readonly _callbacks: EdgeWsConnectionCallbacks,\n ) {\n super();\n }\n\n @logInfo\n public get info() {\n return {\n open: this.isOpen,\n identity: this._identity.identityKey,\n device: this._identity.peerKey,\n };\n }\n\n public get rtt(): number {\n return this._rtt;\n }\n\n public get uptime(): number {\n return this._openTimestamp ? (Date.now() - this._openTimestamp) / 1000 : 0;\n }\n\n public get uploadRate(): number {\n return this._uploadRate;\n }\n\n public get downloadRate(): number {\n return this._downloadRate;\n }\n\n public get messagesSent(): number {\n return this._messagesSent;\n }\n\n public get messagesReceived(): number {\n return this._messagesReceived;\n }\n\n public send(message: Message): void {\n invariant(this._ws);\n invariant(this._wsMuxer);\n log('sending...', { peerKey: this._identity.peerKey, payload: protocol.getPayloadType(message) });\n this._messagesSent++;\n if (this._ws?.protocol.includes(EdgeWebsocketProtocol.V0)) {\n const binary = buf.toBinary(MessageSchema, message);\n if (binary.length > CLOUDFLARE_MESSAGE_MAX_BYTES) {\n log.error('Message dropped because it was too large (>1MB).', {\n byteLength: binary.byteLength,\n serviceId: message.serviceId,\n payload: protocol.getPayloadType(message),\n });\n return;\n }\n this._recordBytes(binary.byteLength, 0);\n this._ws.send(binary);\n } else {\n // For muxer, we need to track the size of the message being sent.\n const binary = buf.toBinary(MessageSchema, message);\n this._recordBytes(binary.byteLength, 0);\n this._wsMuxer.send(message).catch((e) => log.catch(e));\n }\n }\n\n protected override async _open(): Promise<void> {\n const baseProtocols = [...Object.values(EdgeWebsocketProtocol)];\n this._ws = new WebSocket(\n this._connectionInfo.url.toString(),\n this._connectionInfo.protocolHeader\n ? [...baseProtocols, this._connectionInfo.protocolHeader]\n : [...baseProtocols],\n );\n const muxer = new WebSocketMuxer(this._ws);\n this._wsMuxer = muxer;\n\n this._ws.onopen = () => {\n if (this.isOpen) {\n log('connected');\n this._openTimestamp = Date.now();\n this._callbacks.onConnected();\n this._scheduleHeartbeats();\n this._scheduleRateCalculation();\n } else {\n log.verbose('connected after becoming inactive', { currentIdentity: this._identity });\n }\n };\n this._ws.onclose = (event: WebSocket.CloseEvent) => {\n if (this.isOpen) {\n log.warn('server disconnected', { code: event.code, reason: event.reason });\n this._callbacks.onRestartRequired();\n muxer.destroy();\n }\n };\n this._ws.onerror = (event: WebSocket.ErrorEvent) => {\n if (this.isOpen) {\n log.warn('edge connection socket error', { error: event.error, info: event.message });\n this._callbacks.onRestartRequired();\n } else {\n log.verbose('error ignored on closed connection', { error: event.error });\n }\n };\n /**\n * https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data\n */\n this._ws.onmessage = async (event: WebSocket.MessageEvent) => {\n if (!this.isOpen) {\n log.verbose('message ignored on closed connection', { event: event.type });\n return;\n }\n this._lastReceivedMessageTimestamp = Date.now();\n if (event.data === '__pong__') {\n // Calculate latency.\n if (this._pingTimestamp) {\n this._rtt = Date.now() - this._pingTimestamp;\n this._pingTimestamp = undefined;\n }\n this._rescheduleHeartbeatTimeout();\n return;\n }\n const bytes = await toUint8Array(event.data);\n this._recordBytes(0, bytes.byteLength);\n if (!this.isOpen) {\n return;\n }\n\n this._messagesReceived++;\n\n const message = this._ws?.protocol?.includes(EdgeWebsocketProtocol.V0)\n ? buf.fromBinary(MessageSchema, bytes)\n : muxer.receiveData(bytes);\n\n if (message) {\n log('received', { from: message.source, payload: protocol.getPayloadType(message) });\n this._callbacks.onMessage(message);\n }\n };\n }\n\n protected override async _close(): Promise<void> {\n void this._inactivityTimeoutCtx?.dispose().catch(() => {});\n\n try {\n this._ws?.close();\n this._ws = undefined;\n this._wsMuxer?.destroy();\n this._wsMuxer = undefined;\n } catch (err) {\n if (err instanceof Error && err.message.includes('WebSocket is closed before the connection is established.')) {\n return;\n }\n log.warn('error closing websocket', { err });\n }\n }\n\n private _scheduleHeartbeats(): void {\n invariant(this._ws);\n scheduleTaskInterval(\n this._ctx,\n async () => {\n // TODO(mykola): use RFC6455 ping/pong once implemented in the browser?\n // Cloudflare's worker responds to this `without interrupting hibernation`. https://developers.cloudflare.com/durable-objects/api/websockets/#setwebsocketautoresponse\n this._pingTimestamp = Date.now();\n this._ws?.send('__ping__');\n },\n SIGNAL_KEEPALIVE_INTERVAL,\n );\n this._pingTimestamp = Date.now();\n this._ws.send('__ping__');\n this._rescheduleHeartbeatTimeout();\n }\n\n private _rescheduleHeartbeatTimeout(): void {\n if (!this.isOpen) {\n return;\n }\n void this._inactivityTimeoutCtx?.dispose();\n this._inactivityTimeoutCtx = new Context();\n scheduleTask(\n this._inactivityTimeoutCtx,\n () => {\n if (this.isOpen) {\n if (Date.now() - this._lastReceivedMessageTimestamp > SIGNAL_KEEPALIVE_TIMEOUT) {\n log.warn('restart due to inactivity timeout', {\n lastReceivedMessageTimestamp: this._lastReceivedMessageTimestamp,\n });\n this._callbacks.onRestartRequired();\n } else {\n this._rescheduleHeartbeatTimeout();\n }\n }\n },\n SIGNAL_KEEPALIVE_TIMEOUT,\n );\n }\n\n private _recordBytes(sent: number, received: number): void {\n const now = Date.now();\n\n // Find if we have a sample for the current second.\n const currentSecond = Math.floor(now / 1000) * 1000;\n const existingSample = this._bytesSamples.find((s) => Math.floor(s.timestamp / 1000) * 1000 === currentSecond);\n\n if (existingSample) {\n existingSample.sent += sent;\n existingSample.received += received;\n } else {\n this._bytesSamples.push({ timestamp: now, sent, received });\n }\n }\n\n private _scheduleRateCalculation(): void {\n scheduleTaskInterval(\n this._ctx,\n async () => {\n this._calculateRates();\n },\n this._rateUpdateInterval,\n );\n // Calculate initial rates.\n this._calculateRates();\n }\n\n private _calculateRates(): void {\n const now = Date.now();\n const cutoff = now - this._rateWindow;\n\n // Remove old samples.\n this._bytesSamples = this._bytesSamples.filter((s) => s.timestamp > cutoff);\n\n if (this._bytesSamples.length === 0) {\n this._uploadRate = 0;\n this._downloadRate = 0;\n return;\n }\n\n // Calculate total bytes and time span.\n let totalSent = 0;\n let totalReceived = 0;\n const oldestTimestamp = Math.min(...this._bytesSamples.map((s) => s.timestamp));\n const timeSpan = (now - oldestTimestamp) / 1000; // Convert to seconds.\n\n for (const sample of this._bytesSamples) {\n totalSent += sample.sent;\n totalReceived += sample.received;\n }\n\n // Calculate rates (bytes per second).\n this._uploadRate = timeSpan > 0 ? Math.round(totalSent / timeSpan) : 0;\n this._downloadRate = timeSpan > 0 ? Math.round(totalReceived / timeSpan) : 0;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport class EdgeConnectionClosedError extends Error {\n constructor() {\n super('Edge connection closed.');\n }\n}\n\nexport class EdgeIdentityChangedError extends Error {\n constructor() {\n super('Edge identity changed.');\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const getEdgeUrlWithProtocol = (baseUrl: string, protocol: 'http' | 'ws') => {\n const isSecure = baseUrl.startsWith('https') || baseUrl.startsWith('wss');\n const url = new URL(baseUrl);\n url.protocol = protocol + (isSecure ? 's' : '');\n return url.toString();\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as FetchHttpClient from '@effect/platform/FetchHttpClient';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\n\nimport { sleep } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { type PublicKey, type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport {\n type CreateAgentRequestBody,\n type CreateAgentResponseBody,\n type CreateSpaceRequest,\n type CreateSpaceResponseBody,\n EdgeAuthChallengeError,\n EdgeCallFailedError,\n type EdgeFailure,\n type EdgeStatus,\n type ExecuteWorkflowResponseBody,\n type ExportBundleRequest,\n type ExportBundleResponse,\n type FeedProtocol,\n type GetAgentStatusResponseBody,\n type GetNotarizationResponseBody,\n type ImportBundleRequest,\n type InitiateOAuthFlowRequest,\n type InitiateOAuthFlowResponse,\n type JoinSpaceRequest,\n type JoinSpaceResponseBody,\n type ObjectId,\n type PostNotarizationRequestBody,\n type RecoverIdentityRequest,\n type RecoverIdentityResponseBody,\n type UploadFunctionRequest,\n type UploadFunctionResponseBody,\n} from '@dxos/protocols';\nimport { createUrl } from '@dxos/util';\n\nimport { type EdgeIdentity, handleAuthChallenge } from './edge-identity';\nimport { HttpConfig, encodeAuthHeader, withLogging, withRetryConfig } from './http-client';\nimport { getEdgeUrlWithProtocol } from './utils';\n\nconst DEFAULT_RETRY_TIMEOUT = 1500;\nconst DEFAULT_RETRY_JITTER = 500;\nconst DEFAULT_MAX_RETRIES_COUNT = 3;\nconst WARNING_BODY_SIZE = 10 * 1024 * 1024; // 10MB\n\nexport type RetryConfig = {\n /**\n * A number of call retries, not counting the initial request.\n */\n count: number;\n /**\n * Delay before retries in ms.\n */\n timeout?: number;\n /**\n * A random amount of time before retrying to help prevent large bursts of requests.\n */\n jitter?: number;\n};\n\ntype EdgeHttpRequestArgs = {\n method: string;\n context?: Context;\n retry?: RetryConfig;\n body?: any;\n /**\n * @default true\n */\n json?: boolean;\n\n /**\n * Force authentication.\n * This should be used for requests with large bodies to avoid sending the body twice.\n * The client will call /auth endpoint to generate the auth header.\n */\n auth?: boolean;\n};\n\nexport type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'auth'>;\nexport type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body' | 'auth'>;\n\nexport type GetCronTriggersResponse = {\n cronIds: string[];\n};\n\nexport class EdgeHttpClient {\n private readonly _baseUrl: string;\n\n private _edgeIdentity: EdgeIdentity | undefined;\n\n /**\n * Auth header is cached until receiving the next 401 from EDGE, at which point it gets refreshed.\n */\n private _authHeader: string | undefined;\n\n constructor(baseUrl: string) {\n this._baseUrl = getEdgeUrlWithProtocol(baseUrl, 'http');\n log('created', { url: this._baseUrl });\n }\n\n get baseUrl() {\n return this._baseUrl;\n }\n\n setIdentity(identity: EdgeIdentity): void {\n if (this._edgeIdentity?.identityKey !== identity.identityKey || this._edgeIdentity?.peerKey !== identity.peerKey) {\n this._edgeIdentity = identity;\n this._authHeader = undefined;\n }\n }\n\n //\n // Status\n //\n\n public async getStatus(args?: EdgeHttpGetArgs): Promise<EdgeStatus> {\n return this._call(new URL('/status', this.baseUrl), { ...args, method: 'GET', auth: true });\n }\n\n //\n // Agents\n //\n\n public createAgent(body: CreateAgentRequestBody, args?: EdgeHttpGetArgs): Promise<CreateAgentResponseBody> {\n return this._call(new URL('/agents/create', this.baseUrl), { ...args, method: 'POST', body });\n }\n\n public getAgentStatus(\n request: { ownerIdentityKey: PublicKey },\n args?: EdgeHttpGetArgs,\n ): Promise<GetAgentStatusResponseBody> {\n return this._call(new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {\n ...args,\n method: 'GET',\n });\n }\n\n //\n // Credentials\n //\n\n public getCredentialsForNotarization(spaceId: SpaceId, args?: EdgeHttpGetArgs): Promise<GetNotarizationResponseBody> {\n return this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), { ...args, method: 'GET' });\n }\n\n public async notarizeCredentials(\n spaceId: SpaceId,\n body: PostNotarizationRequestBody,\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n await this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Identity\n //\n\n public async recoverIdentity(\n body: RecoverIdentityRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<RecoverIdentityResponseBody> {\n return this._call(new URL('/identity/recover', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Invitations\n //\n\n public async joinSpaceByInvitation(\n spaceId: SpaceId,\n body: JoinSpaceRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<JoinSpaceResponseBody> {\n return this._call(new URL(`/spaces/${spaceId}/join`, this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // OAuth and credentials\n //\n\n public async initiateOAuthFlow(\n body: InitiateOAuthFlowRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<InitiateOAuthFlowResponse> {\n return this._call(new URL('/oauth/initiate', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Spaces\n //\n\n async createSpace(body: CreateSpaceRequest, args?: EdgeHttpGetArgs): Promise<CreateSpaceResponseBody> {\n return this._call(new URL('/spaces/create', this.baseUrl), { ...args, body, method: 'POST' });\n }\n\n //\n // Queues\n //\n\n public async queryQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n query: FeedProtocol.QueueQuery,\n args?: EdgeHttpGetArgs,\n ): Promise<FeedProtocol.QueryResult> {\n const queueId = query.queueIds?.[0];\n invariant(queueId, 'queueId required');\n return this._call(\n createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {\n after: query.after,\n before: query.before,\n limit: query.limit,\n reverse: query.reverse,\n objectIds: query.objectIds?.join(','),\n }),\n {\n ...args,\n method: 'GET',\n },\n );\n }\n\n public async insertIntoQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n queueId: ObjectId,\n objects: unknown[],\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {\n ...args,\n body: { objects },\n method: 'POST',\n });\n }\n\n public async deleteFromQueue(\n subspaceTag: string,\n spaceId: SpaceId,\n queueId: ObjectId,\n objectIds: ObjectId[],\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(\n createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {\n ids: objectIds.join(','),\n }),\n {\n ...args,\n method: 'DELETE',\n },\n );\n }\n\n //\n // Functions\n //\n\n public async uploadFunction(\n pathParts: { functionId?: string },\n body: UploadFunctionRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<UploadFunctionResponseBody> {\n const formData = new FormData();\n formData.append('name', body.name ?? '');\n formData.append('version', body.version);\n formData.append('ownerPublicKey', body.ownerPublicKey);\n formData.append('entryPoint', body.entryPoint);\n body.runtime && formData.append('runtime', body.runtime);\n for (const [filename, content] of Object.entries(body.assets)) {\n formData.append(\n 'assets',\n new Blob([content as Uint8Array<ArrayBuffer>], { type: getFileMimeType(filename) }),\n filename,\n );\n }\n\n const path = ['functions', ...(pathParts.functionId ? [pathParts.functionId] : [])].join('/');\n return this._call(new URL(path, this.baseUrl), {\n ...args,\n body: formData,\n method: 'PUT',\n json: false,\n });\n }\n\n public async listFunctions(args?: EdgeHttpGetArgs): Promise<any> {\n return this._call(new URL('/functions', this.baseUrl), { ...args, method: 'GET' });\n }\n\n public async invokeFunction(\n params: {\n functionId: string;\n version?: string;\n spaceId?: SpaceId;\n cpuTimeLimit?: number;\n subrequestsLimit?: number;\n },\n input: unknown,\n args?: EdgeHttpGetArgs,\n ): Promise<any> {\n const url = new URL(`/functions/${params.functionId}`, this.baseUrl);\n if (params.version) {\n url.searchParams.set('version', params.version);\n }\n if (params.spaceId) {\n url.searchParams.set('spaceId', params.spaceId.toString());\n }\n if (params.cpuTimeLimit) {\n url.searchParams.set('cpuTimeLimit', params.cpuTimeLimit.toString());\n }\n if (params.subrequestsLimit) {\n url.searchParams.set('subrequestsLimit', params.subrequestsLimit.toString());\n }\n\n return this._call(url, {\n ...args,\n body: input,\n method: 'POST',\n });\n }\n\n //\n // Workflows\n //\n\n public async executeWorkflow(\n spaceId: SpaceId,\n graphId: ObjectId,\n input: any,\n args?: EdgeHttpGetArgs,\n ): Promise<ExecuteWorkflowResponseBody> {\n return this._call(new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {\n ...args,\n body: input,\n method: 'POST',\n });\n }\n\n //\n // Triggers\n //\n\n public async getCronTriggers(spaceId: SpaceId): Promise<GetCronTriggersResponse> {\n return this._call<GetCronTriggersResponse>(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), {\n method: 'GET',\n });\n }\n\n public async forceRunCronTrigger(spaceId: SpaceId, triggerId: ObjectId) {\n return this._call(new URL(`/test/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {\n method: 'POST',\n });\n }\n\n //\n // Import/Export space.\n //\n\n public async importBundle(\n spaceId: SpaceId, //\n body: ImportBundleRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<void> {\n return this._call(new URL(`/spaces/${spaceId}/import`, this.baseUrl), { ...args, body, method: 'PUT' });\n }\n\n public async exportBundle(\n spaceId: SpaceId,\n body: ExportBundleRequest,\n args?: EdgeHttpGetArgs,\n ): Promise<ExportBundleResponse> {\n return this._call(new URL(`/spaces/${spaceId}/export`, this.baseUrl), {\n ...args,\n body,\n method: 'POST',\n });\n }\n\n //\n // Internal\n //\n\n private async _fetch<T>(url: URL, _args: EdgeHttpRequestArgs): Promise<T> {\n return Function.pipe(\n HttpClient.get(url),\n withLogging,\n withRetryConfig,\n Effect.provide(FetchHttpClient.layer),\n Effect.provide(HttpConfig.default),\n Effect.withSpan('EdgeHttpClient'),\n runAndForwardErrors,\n ) as T;\n }\n\n // TODO(burdon): Refactor with effect (see edge-http-client.test.ts).\n private async _call<T>(url: URL, args: EdgeHttpRequestArgs): Promise<T> {\n const shouldRetry = createRetryHandler(args);\n const requestContext = args.context ?? Context.default();\n log('fetch', { url, request: args.body });\n\n let handledAuth = false;\n const tryCount = 1;\n while (true) {\n let processingError: EdgeCallFailedError | undefined = undefined;\n try {\n if (!this._authHeader && args.auth) {\n const response = await fetch(new URL(`/auth`, this.baseUrl));\n if (response.status === 401) {\n this._authHeader = await this._handleUnauthorized(response);\n }\n }\n\n const request = createRequest(args, this._authHeader);\n log('call edge', { url, tryCount, authHeader: !!this._authHeader });\n const response = await fetch(url, request);\n\n if (response.ok) {\n const body = await response.clone().json();\n invariant(body, 'Expected body to be present');\n if (!('success' in body)) {\n return body;\n }\n if (body.success) {\n return body.data;\n }\n } else if (response.status === 401 && !handledAuth) {\n this._authHeader = await this._handleUnauthorized(response);\n handledAuth = true;\n continue;\n }\n\n const body: EdgeFailure =\n response.headers.get('Content-Type') === 'application/json' ? await response.clone().json() : undefined;\n\n invariant(!body?.success, 'Expected body to not be a failure response or undefined.');\n\n if (body?.data?.type === 'auth_challenge' && typeof body?.data?.challenge === 'string') {\n processingError = new EdgeAuthChallengeError(body.data.challenge, body.data);\n } else if (body?.success === false) {\n processingError = EdgeCallFailedError.fromUnsuccessfulResponse(response, body);\n } else {\n invariant(!response.ok, 'Expected response to not be ok.');\n processingError = await EdgeCallFailedError.fromHttpFailure(response);\n }\n } catch (error: any) {\n processingError = EdgeCallFailedError.fromProcessingFailureCause(error);\n }\n\n if (processingError?.isRetryable && (await shouldRetry(requestContext, processingError.retryAfterMs))) {\n log.verbose('retrying edge request', { url, processingError });\n } else {\n throw processingError!;\n }\n }\n }\n\n private async _handleUnauthorized(response: Response): Promise<string> {\n if (!this._edgeIdentity) {\n log.warn('unauthorized response received before identity was set');\n throw await EdgeCallFailedError.fromHttpFailure(response);\n }\n\n const challenge = await handleAuthChallenge(response, this._edgeIdentity);\n return encodeAuthHeader(challenge);\n }\n}\n\nconst createRequest = (\n { method, body, json = true }: EdgeHttpRequestArgs,\n authHeader: string | undefined,\n): RequestInit => {\n let requestBody: BodyInit | undefined;\n const headers: HeadersInit = {};\n\n if (json) {\n requestBody = body && JSON.stringify(body);\n headers['Content-Type'] = 'application/json';\n } else {\n requestBody = body;\n }\n\n if (typeof requestBody === 'string' && requestBody.length > WARNING_BODY_SIZE) {\n log.warn('Request with large body', { bodySize: requestBody.length });\n }\n\n if (authHeader) {\n headers['Authorization'] = authHeader;\n }\n\n return {\n method,\n body: requestBody,\n headers,\n };\n};\n\n/**\n * @deprecated\n */\nconst createRetryHandler = ({ retry }: EdgeHttpRequestArgs) => {\n if (!retry || retry.count < 1) {\n return async () => false;\n }\n\n let retries = 0;\n const maxRetries = retry.count ?? DEFAULT_MAX_RETRIES_COUNT;\n const baseTimeout = retry.timeout ?? DEFAULT_RETRY_TIMEOUT;\n const jitter = retry.jitter ?? DEFAULT_RETRY_JITTER;\n return async (ctx: Context, retryAfter?: number) => {\n if (++retries > maxRetries || ctx.disposed) {\n return false;\n }\n\n if (retryAfter) {\n await sleep(retryAfter);\n } else {\n const timeout = baseTimeout + Math.random() * jitter;\n await sleep(timeout);\n }\n\n return true;\n };\n};\n\nconst getFileMimeType = (filename: string) =>\n ['.js', '.mjs'].some((codeExtension) => filename.endsWith(codeExtension))\n ? 'application/javascript+module'\n : filename.endsWith('.wasm')\n ? 'application/wasm'\n : 'application/octet-stream';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as HttpClient from '@effect/platform/HttpClient';\nimport type * as HttpClientError from '@effect/platform/HttpClientError';\nimport type * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Context from 'effect/Context';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Schedule from 'effect/Schedule';\n\nimport { log } from '@dxos/log';\n\n// TODO(burdon): Factor out.\n\nexport type RetryOptions = {\n timeout: Duration.Duration;\n retryTimes: number;\n retryBaseDelay: Duration.Duration;\n};\n\n// Layer pattern.\nexport class HttpConfig extends Context.Tag('HttpConfig')<HttpConfig, RetryOptions>() {\n static default = Layer.succeed(HttpConfig, {\n timeout: Duration.millis(1_000),\n retryTimes: 3,\n retryBaseDelay: Duration.millis(1_000),\n });\n}\n\n// HOC pattern.\nexport const withRetry = (\n effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError, HttpClient.HttpClient>,\n {\n timeout = Duration.millis(1_000),\n retryBaseDelay = Duration.millis(1_000),\n retryTimes = 3,\n }: Partial<RetryOptions> = {},\n) => {\n return effect.pipe(\n Effect.flatMap((res) =>\n // Treat 500 errors as retryable?\n res.status === 500 ? Effect.fail(new Error(res.status.toString())) : res.json,\n ),\n Effect.timeout(timeout),\n Effect.retry({\n schedule: Schedule.exponential(retryBaseDelay).pipe(Schedule.jittered),\n times: retryTimes,\n }),\n );\n};\n\nexport const withRetryConfig = (\n effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError, HttpClient.HttpClient>,\n) =>\n Effect.gen(function* () {\n const config = yield* HttpConfig;\n return yield* withRetry(effect, config);\n });\n\nexport const withLogging = <A extends HttpClientResponse.HttpClientResponse, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(\n Effect.tap((res) => {\n log.info('response', { status: res.status });\n }),\n );\n\n/**\n *\n */\n// TODO(burdon): Document.\nexport const encodeAuthHeader = (challenge: Uint8Array) => {\n const encodedChallenge = Buffer.from(challenge).toString('base64');\n return `VerifiablePresentation pb;base64,${encodedChallenge}`;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;AAIA,cAAc;;;ACAd,SAASA,kBAAkBC,wBAAwB;AAEnD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;;AAQnB,IAAMC,2BAA2B,OAAOC,QAAgBC,QAAAA;AAC7D,SAAO;IACLC,aAAaD,IAAIE,MAAK;IACtBC,SAASH,IAAIE,MAAK;IAClBE,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,aAAOX,iBAAiB;QACtBY,cAAc;UACZC,aAAa;;YAEX,MAAMd,iBAAiB;cACrBe,WAAW;gBACT,SAAS;cACX;cACAC,QAAQT;cACRU,SAASV;cACTD;YACF,CAAA;;QAEJ;QACAA;QACAY,WAAWX;QACXY,OAAOP;MACT,CAAA;IACF;EACF;AACF;AAKO,IAAMQ,0BAA0B,OACrCd,QACAE,aACAE,SACAW,OACAP,gBAAAA;AAEA,QAAMQ,oBACJR,YAAYS,SAAS,IACjBT,cACA;IACE,MAAMd,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,MAAM;AACR6D,kBAAc9G,QAAQ+G,KAAKC,UAAUhH,IAAAA;AACrCgG,YAAQ,cAAA,IAAkB;EAC5B,OAAO;AACLc,kBAAc9G;EAChB;AAEA,MAAI,OAAO8G,gBAAgB,YAAYA,YAAYG,SAAStI,mBAAmB;AAC7EO,IAAAA,KAAIyH,KAAK,2BAA2B;MAAEO,UAAUJ,YAAYG;IAAO,GAAA;;;;;;EACrE;AAEA,MAAItB,YAAY;AACdK,YAAQ,eAAA,IAAmBL;EAC7B;AAEA,SAAO;IACL9F;IACAG,MAAM8G;IACNd;EACF;AACF;AAKA,IAAMjB,qBAAqB,CAAC,EAAEoC,OAAAA,OAAK,MAAuB;AACxD,MAAI,CAACA,UAASA,OAAMC,QAAQ,GAAG;AAC7B,WAAO,YAAY;EACrB;AAEA,MAAIC,UAAU;AACd,QAAMC,aAAaH,OAAMC,SAAS1I;AAClC,QAAM6I,cAAcJ,OAAMK,WAAWhJ;AACrC,QAAMiJ,SAASN,OAAMM,UAAUhJ;AAC/B,SAAO,OAAOiJ,KAAcC,eAAAA;AAC1B,QAAI,EAAEN,UAAUC,cAAcI,IAAIE,UAAU;AAC1C,aAAO;IACT;AAEA,QAAID,YAAY;AACd,YAAME,MAAMF,UAAAA;IACd,OAAO;AACL,YAAMH,WAAUD,cAAcO,KAAKC,OAAM,IAAKN;AAC9C,YAAMI,MAAML,QAAAA;IACd;AAEA,WAAO;EACT;AACF;AAEA,IAAM1E,kBAAkB,CAACP,aACvB;EAAC;EAAO;EAAQyF,KAAK,CAACC,kBAAkB1F,SAAS2F,SAASD,aAAAA,CAAAA,IACtD,kCACA1F,SAAS2F,SAAS,OAAA,IAChB,qBACA;",
6
+ "names": ["createCredential", "signPresentation", "invariant", "Keyring", "PublicKey", "createDeviceEdgeIdentity", "signer", "key", "identityKey", "toHex", "peerKey", "presentCredentials", "challenge", "presentation", "credentials", "assertion", "issuer", "subject", "signerKey", "nonce", "createChainEdgeIdentity", "chain", "credentialsToSign", "length", "signingKey", "createEphemeralEdgeIdentity", "keyring", "createKey", "createTestHaloEdgeIdentity", "deviceKey", "deviceAdmission", "credential", "createStubEdgeIdentity", "random", "Error", "Event", "PersistentLifecycle", "Trigger", "TriggerState", "scheduleMicroTask", "scheduleTaskInterval", "Resource", "log", "logInfo", "EdgeStatus", "invariant", "schema", "handleAuthChallenge", "failedResponse", "identity", "status", "headerValue", "headers", "get", "startsWith", "challenge", "slice", "length", "presentation", "presentCredentials", "Buffer", "from", "getCodecForType", "encode", "WebSocket", "scheduleTask", "scheduleTaskInterval", "Context", "Resource", "invariant", "log", "logInfo", "EdgeWebsocketProtocol", "buf", "MessageSchema", "SIGNAL_KEEPALIVE_INTERVAL", "SIGNAL_KEEPALIVE_TIMEOUT", "EdgeWsConnection", "Resource", "_inactivityTimeoutCtx", "_ws", "_wsMuxer", "_lastReceivedMessageTimestamp", "Date", "now", "_openTimestamp", "_pingTimestamp", "_rtt", "_uploadRate", "_downloadRate", "_rateWindow", "_rateUpdateInterval", "_bytesSamples", "_messagesSent", "_messagesReceived", "_identity", "_connectionInfo", "_callbacks", "info", "open", "isOpen", "identity", "identityKey", "device", "peerKey", "rtt", "uptime", "uploadRate", "downloadRate", "messagesSent", "messagesReceived", "send", "message", "invariant", "log", "payload", "protocol", "getPayloadType", "includes", "EdgeWebsocketProtocol", "V0", "binary", "buf", "toBinary", "MessageSchema", "length", "CLOUDFLARE_MESSAGE_MAX_BYTES", "error", "byteLength", "serviceId", "_recordBytes", "catch", "e", "_open", "baseProtocols", "Object", "values", "WebSocket", "url", "toString", "protocolHeader", "muxer", "WebSocketMuxer", "onopen", "onConnected", "_scheduleHeartbeats", "_scheduleRateCalculation", "verbose", "currentIdentity", "onclose", "event", "warn", "code", "reason", "onRestartRequired", "destroy", "onerror", "onmessage", "type", "data", "undefined", "_rescheduleHeartbeatTimeout", "bytes", "toUint8Array", "fromBinary", "receiveData", "from", "source", "onMessage", "_close", "dispose", "close", "err", "Error", "scheduleTaskInterval", "_ctx", "Context", "scheduleTask", "lastReceivedMessageTimestamp", "sent", "received", "currentSecond", "Math", "floor", "existingSample", "find", "s", "timestamp", "push", "_calculateRates", "cutoff", "filter", "totalSent", "totalReceived", "oldestTimestamp", "min", "map", "timeSpan", "sample", "round", "EdgeConnectionClosedError", "Error", "EdgeIdentityChangedError", "getEdgeUrlWithProtocol", "baseUrl", "protocol", "isSecure", "startsWith", "url", "URL", "toString", "DEFAULT_TIMEOUT", "STATUS_REFRESH_INTERVAL", "EdgeClient", "Resource", "statusChanged", "Event", "_persistentLifecycle", "PersistentLifecycle", "start", "_connect", "stop", "state", "_disconnect", "_messageListeners", "Set", "_reconnectListeners", "_baseWsUrl", "_baseHttpUrl", "_currentConnection", "undefined", "_ready", "Trigger", "_identity", "_config", "getEdgeUrlWithProtocol", "socketEndpoint", "info", "open", "isOpen", "status", "identity", "identityKey", "device", "peerKey", "Boolean", "TriggerState", "RESOLVED", "EdgeStatus", "ConnectionState", "CONNECTED", "NOT_CONNECTED", "uptime", "rtt", "rateBytesUp", "uploadRate", "rateBytesDown", "downloadRate", "messagesSent", "messagesReceived", "setIdentity", "log", "oldIdentity", "_closeCurrentConnection", "EdgeIdentityChangedError", "scheduleRestart", "send", "message", "wait", "timeout", "EdgeConnectionClosedError", "source", "onMessage", "listener", "add", "delete", "onReconnected", "scheduleMicroTask", "_ctx", "has", "error", "catch", "_open", "err", "warn", "scheduleTaskInterval", "emit", "_close", "close", "disposed", "path", "protocolHeader", "disableAuth", "_createAuthHeader", "restartRequired", "url", "URL", "toString", "connection", "EdgeWsConnection", "onConnected", "_isActive", "wake", "_notifyReconnected", "verbose", "onRestartRequired", "_notifyMessageReceived", "from", "type", "payload", "typeUrl", "Promise", "race", "throw", "reset", "protocol", "getPayloadType", "httpUrl", "response", "fetch", "method", "encodePresentationWsAuthHeader", "handleAuthChallenge", "statusText", "encodedPresentation", "encodedToken", "Buffer", "replace", "replaceAll", "FetchHttpClient", "HttpClient", "Effect", "Function", "sleep", "Context", "runAndForwardErrors", "invariant", "log", "EdgeAuthChallengeError", "EdgeCallFailedError", "createUrl", "Context", "Duration", "Effect", "Layer", "Schedule", "log", "HttpConfig", "Tag", "default", "succeed", "timeout", "millis", "retryTimes", "retryBaseDelay", "withRetry", "effect", "pipe", "flatMap", "res", "status", "fail", "Error", "toString", "json", "retry", "schedule", "exponential", "jittered", "times", "withRetryConfig", "gen", "config", "withLogging", "tap", "info", "encodeAuthHeader", "challenge", "encodedChallenge", "Buffer", "from", "DEFAULT_RETRY_TIMEOUT", "DEFAULT_RETRY_JITTER", "DEFAULT_MAX_RETRIES_COUNT", "WARNING_BODY_SIZE", "EdgeHttpClient", "_baseUrl", "_edgeIdentity", "_authHeader", "baseUrl", "getEdgeUrlWithProtocol", "log", "url", "setIdentity", "identity", "identityKey", "peerKey", "undefined", "getStatus", "args", "_call", "URL", "method", "auth", "createAgent", "body", "getAgentStatus", "request", "ownerIdentityKey", "toHex", "getCredentialsForNotarization", "spaceId", "notarizeCredentials", "recoverIdentity", "joinSpaceByInvitation", "initiateOAuthFlow", "createSpace", "queryQueue", "subspaceTag", "query", "queueId", "queueIds", "invariant", "createUrl", "after", "before", "limit", "reverse", "objectIds", "join", "insertIntoQueue", "objects", "deleteFromQueue", "ids", "uploadFunction", "pathParts", "formData", "FormData", "append", "name", "version", "ownerPublicKey", "entryPoint", "runtime", "filename", "content", "Object", "entries", "assets", "Blob", "type", "getFileMimeType", "path", "functionId", "json", "listFunctions", "invokeFunction", "params", "input", "searchParams", "set", "toString", "cpuTimeLimit", "subrequestsLimit", "executeWorkflow", "graphId", "getCronTriggers", "forceRunCronTrigger", "triggerId", "importBundle", "exportBundle", "_fetch", "_args", "pipe", "get", "withLogging", "withRetryConfig", "provide", "layer", "HttpConfig", "default", "withSpan", "runAndForwardErrors", "shouldRetry", "createRetryHandler", "requestContext", "context", "Context", "handledAuth", "tryCount", "processingError", "response", "fetch", "status", "_handleUnauthorized", "createRequest", "authHeader", "ok", "clone", "success", "data", "headers", "challenge", "EdgeAuthChallengeError", "EdgeCallFailedError", "fromUnsuccessfulResponse", "fromHttpFailure", "error", "fromProcessingFailureCause", "isRetryable", "retryAfterMs", "verbose", "warn", "handleAuthChallenge", "encodeAuthHeader", "requestBody", "JSON", "stringify", "length", "bodySize", "retry", "count", "retries", "maxRetries", "baseTimeout", "timeout", "jitter", "ctx", "retryAfter", "disposed", "sleep", "Math", "random", "some", "codeExtension", "endsWith"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/protocol.ts":{"bytes":10133,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/defs.ts":{"bytes":1550,"imports":[{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/edge-ws-muxer.ts":{"bytes":23993,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"}],"format":"esm"},"src/auth.ts":{"bytes":12117,"imports":[{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/edge-identity.ts":{"bytes":3976,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true}],"format":"esm"},"src/edge-ws-connection.ts":{"bytes":37349,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/errors.ts":{"bytes":1188,"imports":[],"format":"esm"},"src/utils.ts":{"bytes":1398,"imports":[],"format":"esm"},"src/edge-client.ts":{"bytes":37723,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-connection.ts","kind":"import-statement","original":"./edge-ws-connection"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/http-client.ts":{"bytes":7286,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/edge-http-client.ts":{"bytes":51956,"imports":[{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/index.ts":{"bytes":1375,"imports":[{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/auth.ts","kind":"import-statement","original":"./auth"},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-client.ts","kind":"import-statement","original":"./edge-client"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"},{"path":"src/edge-http-client.ts","kind":"import-statement","original":"./edge-http-client"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"}],"format":"esm"},"src/testing/test-server.ts":{"bytes":4545,"imports":[{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/testing/test-utils.ts":{"bytes":14013,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"../defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"../edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"../protocol"}],"format":"esm"},"src/testing/index.ts":{"bytes":570,"imports":[{"path":"src/testing/test-server.ts","kind":"import-statement","original":"./test-server"},{"path":"src/testing/test-utils.ts","kind":"import-statement","original":"./test-utils"}],"format":"esm"}},"outputs":{"dist/lib/neutral/edge-ws-muxer.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/edge-ws-muxer.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-VESGVCLQ.mjs","kind":"import-statement"}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","WebSocketMuxer"],"entryPoint":"src/edge-ws-muxer.ts","inputs":{},"bytes":249},"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":74093},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-VESGVCLQ.mjs","kind":"import-statement"},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","EdgeClient","EdgeConnectionClosedError","EdgeHttpClient","EdgeIdentityChangedError","HttpConfig","Protocol","WebSocketMuxer","createChainEdgeIdentity","createDeviceEdgeIdentity","createEphemeralEdgeIdentity","createStubEdgeIdentity","createTestHaloEdgeIdentity","encodeAuthHeader","getTypename","handleAuthChallenge","protocol","toUint8Array","withLogging","withRetry","withRetryConfig"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":60},"src/auth.ts":{"bytesInOutput":2963},"src/edge-client.ts":{"bytesInOutput":10071},"src/edge-identity.ts":{"bytesInOutput":1158},"src/edge-ws-connection.ts":{"bytesInOutput":10215},"src/errors.ts":{"bytesInOutput":232},"src/utils.ts":{"bytesInOutput":244},"src/edge-http-client.ts":{"bytesInOutput":12668},"src/http-client.ts":{"bytesInOutput":1552}},"bytes":40097},"dist/lib/neutral/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9555},"dist/lib/neutral/testing/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-VESGVCLQ.mjs","kind":"import-statement"},{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true}],"exports":["DEFAULT_PORT","createTestEdgeWsServer","createTestServer","responseHandler"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-server.ts":{"bytesInOutput":1151},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/test-utils.ts":{"bytesInOutput":3678}},"bytes":5103},"dist/lib/neutral/chunk-VESGVCLQ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17259},"dist/lib/neutral/chunk-VESGVCLQ.mjs":{"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","Protocol","WebSocketMuxer","getTypename","protocol","toUint8Array"],"inputs":{"src/edge-ws-muxer.ts":{"bytesInOutput":5688},"src/defs.ts":{"bytesInOutput":298},"src/protocol.ts":{"bytesInOutput":2604}},"bytes":8880}}}
@@ -2,24 +2,67 @@ import {
2
2
  WebSocketMuxer,
3
3
  protocol,
4
4
  toUint8Array
5
- } from "../chunk-VHS3XEIX.mjs";
5
+ } from "../chunk-VESGVCLQ.mjs";
6
6
 
7
- // packages/core/mesh/edge-client/src/testing/test-utils.ts
7
+ // src/testing/test-server.ts
8
+ import http from "@dxos/node-std/http";
9
+ import { log } from "@dxos/log";
10
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/testing/test-server.ts";
11
+ var createTestServer = (responseHandler2) => {
12
+ const server = http.createServer(responseHandler2);
13
+ return new Promise((resolve) => {
14
+ server.listen(0, () => {
15
+ const address = server.address();
16
+ const port = typeof address === "object" && address ? address.port : 0;
17
+ resolve({
18
+ url: `http://localhost:${port}`,
19
+ close: () => server.close()
20
+ });
21
+ });
22
+ });
23
+ };
24
+ var responseHandler = (cb) => {
25
+ let attempt = 0;
26
+ return (req, res) => {
27
+ const data = cb(++attempt) ?? {};
28
+ if (data === false) {
29
+ log("simulating failure", {
30
+ attempt
31
+ }, {
32
+ F: __dxlog_file,
33
+ L: 36,
34
+ S: void 0,
35
+ C: (f, a) => f(...a)
36
+ });
37
+ res.statusCode = 500;
38
+ res.statusMessage = "Simulating failure";
39
+ res.end("");
40
+ } else {
41
+ res.writeHead(200, {
42
+ "Content-Type": "application/json"
43
+ });
44
+ res.end(JSON.stringify({
45
+ success: true,
46
+ data
47
+ }));
48
+ }
49
+ };
50
+ };
51
+
52
+ // src/testing/test-utils.ts
8
53
  import WebSocket from "isomorphic-ws";
9
54
  import { Trigger } from "@dxos/async";
10
- import { log } from "@dxos/log";
55
+ import { log as log2 } from "@dxos/log";
11
56
  import { EdgeWebsocketProtocol } from "@dxos/protocols";
12
57
  import { buf } from "@dxos/protocols/buf";
13
58
  import { MessageSchema, TextMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
14
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/edge-client/src/testing/test-utils.ts";
59
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/edge-client/src/testing/test-utils.ts";
15
60
  var DEFAULT_PORT = 8080;
16
61
  var createTestEdgeWsServer = async (port = DEFAULT_PORT, params) => {
17
62
  const wsServer = new WebSocket.Server({
18
63
  port,
19
64
  verifyClient: createConnectionDelayHandler(params),
20
- handleProtocols: () => [
21
- EdgeWebsocketProtocol.V1
22
- ]
65
+ handleProtocols: () => EdgeWebsocketProtocol.V1
23
66
  });
24
67
  let connection;
25
68
  const messageSink = [];
@@ -32,8 +75,8 @@ var createTestEdgeWsServer = async (port = DEFAULT_PORT, params) => {
32
75
  ws,
33
76
  muxer
34
77
  };
35
- ws.on("error", (err) => log.catch(err, void 0, {
36
- F: __dxlog_file,
78
+ ws.on("error", (err) => log2.catch(err, void 0, {
79
+ F: __dxlog_file2,
37
80
  L: 42,
38
81
  S: void 0,
39
82
  C: (f, a) => f(...a)
@@ -55,10 +98,10 @@ var createTestEdgeWsServer = async (port = DEFAULT_PORT, params) => {
55
98
  sendResponseMessage(request, responsePayload);
56
99
  }
57
100
  }
58
- log("message", {
101
+ log2("message", {
59
102
  payload: requestPayload
60
103
  }, {
61
- F: __dxlog_file,
104
+ F: __dxlog_file2,
62
105
  L: 60,
63
106
  S: void 0,
64
107
  C: (f, a) => f(...a)
@@ -91,16 +134,16 @@ var createTestEdgeWsServer = async (port = DEFAULT_PORT, params) => {
91
134
  var createConnectionDelayHandler = (params) => {
92
135
  return (_, callback) => {
93
136
  if (params?.admitConnection) {
94
- log("delaying edge connection admission", void 0, {
95
- F: __dxlog_file,
137
+ log2("delaying edge connection admission", void 0, {
138
+ F: __dxlog_file2,
96
139
  L: 92,
97
140
  S: void 0,
98
141
  C: (f, a) => f(...a)
99
142
  });
100
143
  void params.admitConnection.wait().then(() => {
101
144
  callback(true);
102
- log("edge connection admitted", void 0, {
103
- F: __dxlog_file,
145
+ log2("edge connection admitted", void 0, {
146
+ F: __dxlog_file2,
104
147
  L: 95,
105
148
  S: void 0,
106
149
  C: (f, a) => f(...a)
@@ -135,6 +178,8 @@ var decodePayload = async (request, params) => {
135
178
  };
136
179
  export {
137
180
  DEFAULT_PORT,
138
- createTestEdgeWsServer
181
+ createTestEdgeWsServer,
182
+ createTestServer,
183
+ responseHandler
139
184
  };
140
185
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/testing/test-server.ts", "../../../../src/testing/test-utils.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport http from 'node:http';\n\nimport { log } from '@dxos/log';\n\nexport type TestServer = {\n url: string;\n close: () => void;\n};\n\nexport type ResponseHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void;\n\nexport const createTestServer = (responseHandler: ResponseHandler) => {\n const server = http.createServer(responseHandler);\n\n return new Promise<TestServer>((resolve) => {\n server.listen(0, () => {\n const address = server.address();\n const port = typeof address === 'object' && address ? address.port : 0;\n resolve({\n url: `http://localhost:${port}`,\n close: () => server.close(),\n });\n });\n });\n};\n\nexport const responseHandler = (cb: (attempt: number) => false | object): ResponseHandler => {\n let attempt = 0;\n return (req, res) => {\n const data = cb(++attempt) ?? {};\n if (data === false) {\n log('simulating failure', { attempt });\n res.statusCode = 500;\n res.statusMessage = 'Simulating failure';\n res.end('');\n } else {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ success: true, data }));\n }\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema, TextMessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from '../defs';\nimport { WebSocketMuxer } from '../edge-ws-muxer';\nimport { toUint8Array } from '../protocol';\n\nexport const DEFAULT_PORT = 8080;\n\ntype TestEdgeWsServerProps = {\n admitConnection?: Trigger;\n payloadDecoder?: (payload: Uint8Array) => any;\n messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;\n};\n\nexport const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestEdgeWsServerProps) => {\n const wsServer = new WebSocket.Server({\n port,\n verifyClient: createConnectionDelayHandler(params),\n handleProtocols: () => EdgeWebsocketProtocol.V1,\n });\n\n let connection: { ws: WebSocket; muxer: WebSocketMuxer } | undefined;\n\n const messageSink: any[] = [];\n const messageSourceLog: any[] = [];\n const closeTrigger = new Trigger();\n const sendResponseMessage = createResponseSender(() => connection!.muxer);\n\n wsServer.on('connection', (ws: WebSocket) => {\n const muxer = new WebSocketMuxer(ws);\n connection = { ws, muxer };\n ws.on('error', (err: Error) => log.catch(err));\n ws.on('message', async (data: any) => {\n if (String(data) === '__ping__') {\n ws.send('__pong__');\n return;\n }\n const message = muxer.receiveData(await toUint8Array(data));\n if (!message) {\n return;\n }\n const { request, requestPayload } = await decodePayload(message, params);\n messageSourceLog.push(request.source);\n if (params?.messageHandler) {\n const responsePayload = await params.messageHandler(requestPayload);\n if (responsePayload && connection) {\n sendResponseMessage(request, responsePayload);\n }\n }\n log('message', { payload: requestPayload });\n messageSink.push(requestPayload);\n });\n\n ws.on('close', () => {\n connection = undefined;\n closeTrigger.wake();\n });\n });\n\n return {\n server: wsServer,\n messageSink,\n messageSourceLog,\n endpoint: `ws://127.0.0.1:${port}`,\n cleanup: () => wsServer.close(),\n currentConnection: () => connection,\n sendResponseMessage,\n sendMessage: (msg: Message) => {\n return connection!.muxer.send(msg);\n },\n closeConnection: () => {\n closeTrigger.reset();\n connection!.ws.close(1011);\n return closeTrigger.wait();\n },\n };\n};\n\nconst createConnectionDelayHandler = (params: TestEdgeWsServerProps | undefined) => {\n return (_: any, callback: (admit: boolean) => void) => {\n if (params?.admitConnection) {\n log('delaying edge connection admission');\n void params.admitConnection.wait().then(() => {\n callback(true);\n log('edge connection admitted');\n });\n } else {\n callback(true);\n }\n };\n};\n\nconst createResponseSender = (connection: () => WebSocketMuxer) => {\n return (request: Message, responsePayload: Uint8Array) => {\n const recipient = request.source!;\n void connection().send(\n buf.create(MessageSchema, {\n source: {\n identityKey: recipient.identityKey,\n peerKey: recipient.peerKey,\n },\n serviceId: request.serviceId!,\n payload: { value: responsePayload },\n }),\n );\n };\n};\n\nconst decodePayload = async (request: Message, params: TestEdgeWsServerProps | undefined) => {\n const requestPayload = params?.payloadDecoder\n ? params.payloadDecoder(request.payload!.value!)\n : protocol.getPayload(request, TextMessageSchema);\n return { request, requestPayload };\n};\n"],
5
+ "mappings": ";;;;;;;AAIA,OAAOA,UAAU;AAEjB,SAASC,WAAW;;AASb,IAAMC,mBAAmB,CAACC,qBAAAA;AAC/B,QAAMC,SAASJ,KAAKK,aAAaF,gBAAAA;AAEjC,SAAO,IAAIG,QAAoB,CAACC,YAAAA;AAC9BH,WAAOI,OAAO,GAAG,MAAA;AACf,YAAMC,UAAUL,OAAOK,QAAO;AAC9B,YAAMC,OAAO,OAAOD,YAAY,YAAYA,UAAUA,QAAQC,OAAO;AACrEH,cAAQ;QACNI,KAAK,oBAAoBD,IAAAA;QACzBE,OAAO,MAAMR,OAAOQ,MAAK;MAC3B,CAAA;IACF,CAAA;EACF,CAAA;AACF;AAEO,IAAMT,kBAAkB,CAACU,OAAAA;AAC9B,MAAIC,UAAU;AACd,SAAO,CAACC,KAAKC,QAAAA;AACX,UAAMC,OAAOJ,GAAG,EAAEC,OAAAA,KAAY,CAAC;AAC/B,QAAIG,SAAS,OAAO;AAClBhB,UAAI,sBAAsB;QAAEa;MAAQ,GAAA;;;;;;AACpCE,UAAIE,aAAa;AACjBF,UAAIG,gBAAgB;AACpBH,UAAII,IAAI,EAAA;IACV,OAAO;AACLJ,UAAIK,UAAU,KAAK;QAAE,gBAAgB;MAAmB,CAAA;AACxDL,UAAII,IAAIE,KAAKC,UAAU;QAAEC,SAAS;QAAMP;M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D,eAAehC,QAAQO,QAASwB,KAAK,IAC5CE,SAASC,WAAWlC,SAASmC,iBAAAA;AACjC,SAAO;IAAEnC;IAASC;EAAe;AACnC;",
6
+ "names": ["http", "log", "createTestServer", "responseHandler", "server", "createServer", "Promise", "resolve", "listen", "address", "port", "url", "close", "cb", "attempt", "req", "res", "data", "statusCode", "statusMessage", "end", "writeHead", "JSON", "stringify", "success", "WebSocket", "Trigger", "log", "EdgeWebsocketProtocol", "buf", "MessageSchema", "TextMessageSchema", "DEFAULT_PORT", "createTestEdgeWsServer", "port", "params", "wsServer", "WebSocket", "Server", "verifyClient", "createConnectionDelayHandler", "handleProtocols", "EdgeWebsocketProtocol", "V1", "connection", "messageSink", "messageSourceLog", "closeTrigger", "Trigger", "sendResponseMessage", "createResponseSender", "muxer", "on", "ws", "WebSocketMuxer", "err", "log", "catch", "data", "String", "send", "message", "receiveData", "toUint8Array", "request", "requestPayload", "decodePayload", "push", "source", "messageHandler", "responsePayload", "payload", "undefined", "wake", "server", "endpoint", "cleanup", "close", "currentConnection", "sendMessage", "msg", "closeConnection", "reset", "wait", "_", "callback", "admitConnection", "then", "recipient", "buf", "create", "MessageSchema", "identityKey", "peerKey", "serviceId", "value", "payloadDecoder", "protocol", "getPayload", "TextMessageSchema"]
7
+ }
@@ -1,11 +1,17 @@
1
1
  import { Event } from '@dxos/async';
2
- import { Resource, type Lifecycle } from '@dxos/context';
2
+ import { type Lifecycle, Resource } from '@dxos/context';
3
3
  import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
4
4
  import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
5
5
  import { type EdgeIdentity } from './edge-identity';
6
6
  import { type Protocol } from './protocol';
7
7
  export type MessageListener = (message: Message) => void;
8
8
  export type ReconnectListener = () => void;
9
+ export type MessengerConfig = {
10
+ socketEndpoint: string;
11
+ timeout?: number;
12
+ protocol?: Protocol;
13
+ disableAuth?: boolean;
14
+ };
9
15
  export interface EdgeConnection extends Required<Lifecycle> {
10
16
  statusChanged: Event<EdgeStatus>;
11
17
  get info(): any;
@@ -14,16 +20,10 @@ export interface EdgeConnection extends Required<Lifecycle> {
14
20
  get isOpen(): boolean;
15
21
  get status(): EdgeStatus;
16
22
  setIdentity(identity: EdgeIdentity): void;
23
+ send(message: Message): Promise<void>;
17
24
  onMessage(listener: MessageListener): () => void;
18
25
  onReconnected(listener: ReconnectListener): () => void;
19
- send(message: Message): Promise<void>;
20
26
  }
21
- export type MessengerConfig = {
22
- socketEndpoint: string;
23
- timeout?: number;
24
- protocol?: Protocol;
25
- disableAuth?: boolean;
26
- };
27
27
  /**
28
28
  * Messenger client for EDGE:
29
29
  * - While open, uses PersistentLifecycle to keep an open EdgeWsConnection, reconnecting on failures.
@@ -52,8 +52,13 @@ export declare class EdgeClient extends Resource implements EdgeConnection {
52
52
  get identityKey(): string;
53
53
  get peerKey(): string;
54
54
  setIdentity(identity: EdgeIdentity): void;
55
- onMessage(listener: MessageListener): () => void;
56
- onReconnected(listener: () => void): () => void;
55
+ /**
56
+ * Send message.
57
+ * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
58
+ */
59
+ send(message: Message): Promise<void>;
60
+ onMessage(listener: MessageListener): () => boolean;
61
+ onReconnected(listener: () => void): () => boolean;
57
62
  /**
58
63
  * Open connection to messaging service.
59
64
  */
@@ -67,11 +72,6 @@ export declare class EdgeClient extends Resource implements EdgeConnection {
67
72
  private _closeCurrentConnection;
68
73
  private _notifyReconnected;
69
74
  private _notifyMessageReceived;
70
- /**
71
- * Send message.
72
- * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
73
- */
74
- send(message: Message): Promise<void>;
75
75
  private _createAuthHeader;
76
76
  private _isActive;
77
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../../src/edge-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,QAA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D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGlC;IAEH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8B;IAChE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAgC;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,kBAAkB,CAAC,CAA+B;IAC1D,OAAO,CAAC,MAAM,CAAiB;gBAGrB,SAAS,EAAE,YAAY,EACd,OAAO,EAAE,eAAe;IAO3C,IACW,IAAI;;;;;MAOd;IAED,IAAI,MAAM,IAAI,UAAU,CAavB;IAED,IAAI,WAAW,WAEd;IAED,IAAI,OAAO,WAEV;IAED,WAAW,CAAC,QAAQ,EAAE,YAAY;IASlC;;;OAGG;IACU,IAAI,CAAC,OAAO,EAAE,OAAO;IAoB3B,SAAS,CAAC,QAAQ,EAAE,eAAe;IAKnC,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI;IAmBzC;;OAEG;cACsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB/C;;OAEG;cACsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAMlC,QAAQ;YA0DR,WAAW;IAKzB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,sBAAsB;YAUhB,iBAAiB;IAY/B,OAAO,CAAC,SAAS,CAA4E;CAC9F"}
@@ -1,7 +1,42 @@
1
1
  import { Context } from '@dxos/context';
2
2
  import { type PublicKey, type SpaceId } from '@dxos/keys';
3
- import { type GetNotarizationResponseBody, type PostNotarizationRequestBody, type JoinSpaceRequest, type JoinSpaceResponseBody, type CreateAgentResponseBody, type CreateAgentRequestBody, type GetAgentStatusResponseBody, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody, type ObjectId, type ExecuteWorkflowResponseBody, type QueueQuery, type QueryResult, type InitiateOAuthFlowRequest, type InitiateOAuthFlowResponse, type CreateSpaceRequest, type CreateSpaceResponseBody } from '@dxos/protocols';
3
+ import { type CreateAgentRequestBody, type CreateAgentResponseBody, type CreateSpaceRequest, type CreateSpaceResponseBody, type EdgeStatus, type ExecuteWorkflowResponseBody, type ExportBundleRequest, type ExportBundleResponse, type FeedProtocol, type GetAgentStatusResponseBody, type GetNotarizationResponseBody, type ImportBundleRequest, type InitiateOAuthFlowRequest, type InitiateOAuthFlowResponse, type JoinSpaceRequest, type JoinSpaceResponseBody, type ObjectId, type PostNotarizationRequestBody, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody } from '@dxos/protocols';
4
4
  import { type EdgeIdentity } from './edge-identity';
5
+ export type RetryConfig = {
6
+ /**
7
+ * A number of call retries, not counting the initial request.
8
+ */
9
+ count: number;
10
+ /**
11
+ * Delay before retries in ms.
12
+ */
13
+ timeout?: number;
14
+ /**
15
+ * A random amount of time before retrying to help prevent large bursts of requests.
16
+ */
17
+ jitter?: number;
18
+ };
19
+ type EdgeHttpRequestArgs = {
20
+ method: string;
21
+ context?: Context;
22
+ retry?: RetryConfig;
23
+ body?: any;
24
+ /**
25
+ * @default true
26
+ */
27
+ json?: boolean;
28
+ /**
29
+ * Force authentication.
30
+ * This should be used for requests with large bodies to avoid sending the body twice.
31
+ * The client will call /auth endpoint to generate the auth header.
32
+ */
33
+ auth?: boolean;
34
+ };
35
+ export type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'auth'>;
36
+ export type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body' | 'auth'>;
37
+ export type GetCronTriggersResponse = {
38
+ cronIds: string[];
39
+ };
5
40
  export declare class EdgeHttpClient {
6
41
  private readonly _baseUrl;
7
42
  private _edgeIdentity;
@@ -12,47 +47,40 @@ export declare class EdgeHttpClient {
12
47
  constructor(baseUrl: string);
13
48
  get baseUrl(): string;
14
49
  setIdentity(identity: EdgeIdentity): void;
50
+ getStatus(args?: EdgeHttpGetArgs): Promise<EdgeStatus>;
15
51
  createAgent(body: CreateAgentRequestBody, args?: EdgeHttpGetArgs): Promise<CreateAgentResponseBody>;
16
52
  getAgentStatus(request: {
17
53
  ownerIdentityKey: PublicKey;
18
54
  }, args?: EdgeHttpGetArgs): Promise<GetAgentStatusResponseBody>;
19
55
  getCredentialsForNotarization(spaceId: SpaceId, args?: EdgeHttpGetArgs): Promise<GetNotarizationResponseBody>;
20
56
  notarizeCredentials(spaceId: SpaceId, body: PostNotarizationRequestBody, args?: EdgeHttpGetArgs): Promise<void>;
21
- joinSpaceByInvitation(spaceId: SpaceId, body: JoinSpaceRequest, args?: EdgeHttpGetArgs): Promise<JoinSpaceResponseBody>;
22
57
  recoverIdentity(body: RecoverIdentityRequest, args?: EdgeHttpGetArgs): Promise<RecoverIdentityResponseBody>;
23
- executeWorkflow(spaceId: SpaceId, graphId: ObjectId, input: any, args?: EdgeHttpGetArgs): Promise<ExecuteWorkflowResponseBody>;
24
- uploadFunction(pathParts: {
25
- functionId?: string;
26
- }, body: UploadFunctionRequest, args?: EdgeHttpGetArgs): Promise<UploadFunctionResponseBody>;
58
+ joinSpaceByInvitation(spaceId: SpaceId, body: JoinSpaceRequest, args?: EdgeHttpGetArgs): Promise<JoinSpaceResponseBody>;
27
59
  initiateOAuthFlow(body: InitiateOAuthFlowRequest, args?: EdgeHttpGetArgs): Promise<InitiateOAuthFlowResponse>;
28
- queryQueue(subspaceTag: string, spaceId: SpaceId, query: QueueQuery, args?: EdgeHttpGetArgs): Promise<QueryResult>;
60
+ createSpace(body: CreateSpaceRequest, args?: EdgeHttpGetArgs): Promise<CreateSpaceResponseBody>;
61
+ queryQueue(subspaceTag: string, spaceId: SpaceId, query: FeedProtocol.QueueQuery, args?: EdgeHttpGetArgs): Promise<FeedProtocol.QueryResult>;
29
62
  insertIntoQueue(subspaceTag: string, spaceId: SpaceId, queueId: ObjectId, objects: unknown[], args?: EdgeHttpGetArgs): Promise<void>;
30
63
  deleteFromQueue(subspaceTag: string, spaceId: SpaceId, queueId: ObjectId, objectIds: ObjectId[], args?: EdgeHttpGetArgs): Promise<void>;
31
- createSpace(body: CreateSpaceRequest, args?: EdgeHttpGetArgs): Promise<CreateSpaceResponseBody>;
64
+ uploadFunction(pathParts: {
65
+ functionId?: string;
66
+ }, body: UploadFunctionRequest, args?: EdgeHttpGetArgs): Promise<UploadFunctionResponseBody>;
67
+ listFunctions(args?: EdgeHttpGetArgs): Promise<any>;
68
+ invokeFunction(params: {
69
+ functionId: string;
70
+ version?: string;
71
+ spaceId?: SpaceId;
72
+ cpuTimeLimit?: number;
73
+ subrequestsLimit?: number;
74
+ }, input: unknown, args?: EdgeHttpGetArgs): Promise<any>;
75
+ executeWorkflow(spaceId: SpaceId, graphId: ObjectId, input: any, args?: EdgeHttpGetArgs): Promise<ExecuteWorkflowResponseBody>;
76
+ getCronTriggers(spaceId: SpaceId): Promise<GetCronTriggersResponse>;
77
+ forceRunCronTrigger(spaceId: SpaceId, triggerId: ObjectId): Promise<unknown>;
78
+ importBundle(spaceId: SpaceId, //
79
+ body: ImportBundleRequest, args?: EdgeHttpGetArgs): Promise<void>;
80
+ exportBundle(spaceId: SpaceId, body: ExportBundleRequest, args?: EdgeHttpGetArgs): Promise<ExportBundleResponse>;
81
+ private _fetch;
32
82
  private _call;
33
83
  private _handleUnauthorized;
34
84
  }
35
- export type RetryConfig = {
36
- /**
37
- * A number of call retries, not counting the initial request.
38
- */
39
- count: number;
40
- /**
41
- * Delay before retries in ms.
42
- */
43
- timeout?: number;
44
- /**
45
- * A random amount of time before retrying to help prevent large bursts of requests.
46
- */
47
- jitter?: number;
48
- };
49
- export type EdgeHttpGetArgs = {
50
- context?: Context;
51
- retry?: RetryConfig;
52
- };
53
- export type EdgeHttpPostArgs = {
54
- context?: Context;
55
- body?: any;
56
- retry?: RetryConfig;
57
- };
85
+ export {};
58
86
  //# sourceMappingURL=edge-http-client.d.ts.map