{"version":3,"sources":["../src/index.ts","../src/harrr-connection.ts","../src/models/remote-reference.ts","../src/models/cancellation-token-reference.ts","../src/models/stream-reference.ts","../src/models/harrr-error.ts","../src/harrr-connection-options.ts","../src/cancellation-manager.ts"],"sourcesContent":["export { HARRRConnection } from './harrr-connection.js';\nexport { HARRRConnectionOptions } from './harrr-connection-options.js';\nexport type { Credential } from './harrr-connection-options.js';\nexport type { ClientRequestMessage } from './models/client-request-message.js';\nexport type { ServerRequestMessage } from './models/server-request-message.js';\nexport type { CancellationTokenReference } from './models/cancellation-token-reference.js';\nexport { REMOTE_REFERENCE_PROPERTY, RemoteReferenceKind } from './models/remote-reference.js';\nexport type { StreamReference } from './models/stream-reference.js';\nexport { isStreamReference, resolveStreamReference, resolveStreamReferenceAsStream, transferAuthHeaders } from './models/stream-reference.js';\nexport type { HARRRError, HARRRInvocationError } from './models/harrr-error.js';\nexport { parseHARRRError, HARRRErrorCodes, normalizeErrorCode } from './models/harrr-error.js';\n","import * as signalR from '@microsoft/signalr';\nimport { ClientRequestMessage } from './models/client-request-message.js';\nimport { ServerRequestMessage } from './models/server-request-message.js';\nimport { asCancellationTokenReference } from './models/cancellation-token-reference.js';\nimport { isStreamReference, resolveStreamReference, transferAuthHeaders } from './models/stream-reference.js';\nimport { parseHARRRError, normalizeErrorCode, type HARRRInvocationError } from './models/harrr-error.js';\nimport {\n  HARRRConnectionOptions,\n  credentialFactory,\n  resolveConnectionCredential,\n  resolveMessageCredential,\n} from './harrr-connection-options.js';\nimport { CancellationManager } from './cancellation-manager.js';\n\nexport class HARRRConnection {\n  private _hubConnection: signalR.HubConnection;\n  // The credential SignalARRR sends, as opposed to the one SignalR sends. Set through\n  // HARRRConnectionOptions.authorization; see the note there for why it is no longer adopted from\n  // the transport. Awaited on every path: SignalR's contract allows a promise, every OAuth-backed\n  // application returns one, and serialising the promise itself put `{}` on the wire, which the\n  // server — where the field is a string — could not bind.\n  private _authorization: () => string | Promise<string> = () => '';\n  private _serverRequestHandlers = new Map<string, (...args: unknown[]) => unknown>();\n  private _serverStreamHandlers = new Map<string, (...args: unknown[]) => AsyncIterable<unknown>>();\n  private _cancellationManager = new CancellationManager();\n\n  public get baseUrl(): string {\n    return this._hubConnection.baseUrl;\n  }\n\n  public set baseUrl(value: string) {\n    this._hubConnection.baseUrl = value;\n  }\n\n  public get connectionId(): string | null {\n    return this._hubConnection.connectionId;\n  }\n\n  public get state(): signalR.HubConnectionState {\n    return this._hubConnection.state;\n  }\n\n  public get serverTimeoutInMilliseconds(): number {\n    return this._hubConnection.serverTimeoutInMilliseconds;\n  }\n\n  public set serverTimeoutInMilliseconds(value: number) {\n    this._hubConnection.serverTimeoutInMilliseconds = value;\n  }\n\n  public get keepAliveIntervalInMilliseconds(): number {\n    return this._hubConnection.keepAliveIntervalInMilliseconds;\n  }\n\n  public set keepAliveIntervalInMilliseconds(value: number) {\n    this._hubConnection.keepAliveIntervalInMilliseconds = value;\n  }\n\n  /**\n   * Wraps a `HubConnection` that is already built. Its connection credential is SignalR's own\n   * `accessTokenFactory`; only the message credential can be set here.\n   */\n  constructor(hubConnection: signalR.HubConnection, options?: HARRRConnectionOptions) {\n    if (resolveConnectionCredential(options) !== undefined) {\n      throw new Error(\n        'A connection credential cannot be applied to a HubConnection that is already built — SignalR fixed its accessTokenFactory when it was built. ' +\n          'Use HARRRConnection.create(url, options) instead, or set accessTokenFactory in withUrl yourself and only messageCredential here.',\n      );\n    }\n    this._hubConnection = hubConnection;\n\n    const messageCredential = resolveMessageCredential(options);\n    if (messageCredential !== undefined) {\n      this._authorization = credentialFactory(messageCredential);\n    }\n\n    // Native client results — return values are sent back to the server automatically by SignalR.\n    // A promise is fine here without awaiting it ourselves: SignalR awaits the return value of a\n    // client-result handler before completing the invocation.\n    this._hubConnection.on('ChallengeAuthentication', (req: ServerRequestMessage) => {\n      return this._authorization();\n    });\n\n    this._hubConnection.on('InvokeServerRequest', async (req: ServerRequestMessage) => {\n      // If StreamId is present, stream results back instead of returning a single value\n      if (req.StreamId) {\n        await this._streamBackToServer(req, req.StreamId);\n        return undefined;\n      }\n      const result = await this._dispatchServerMethod(req);\n\n      // If the result is binary data (Blob, ArrayBuffer, Buffer), upload via HTTP\n      // and return a StreamReference instead\n      if (result instanceof Blob || result instanceof ArrayBuffer ||\n          isNodeBuffer(result)) {\n        return await this._uploadAndReturnReference(result);\n      }\n\n      return result;\n    });\n\n    this._hubConnection.on('InvokeServerMessage', async (req: ServerRequestMessage) => {\n      try {\n        if (req.StreamId) {\n          await this._streamBackToServer(req, req.StreamId);\n        } else {\n          await this._dispatchServerMethod(req);\n        }\n      } catch (err) {\n        console.error(`[SignalARRR] Failed to handle server message '${req.Method}':`, err);\n      }\n    });\n\n    this._hubConnection.on('CancelTokenFromServer', (req: ServerRequestMessage) => {\n      if (req.CancellationGuid) {\n        this._cancellationManager.cancel(req.CancellationGuid);\n      }\n    });\n  }\n\n  private async _dispatchServerMethod(req: ServerRequestMessage): Promise<unknown> {\n    const handler = this._serverRequestHandlers.get(req.Method);\n    if (!handler) return undefined;\n\n    const args = await this._prepareArgs(req);\n    return await handler(...args);\n  }\n\n  private async _prepareArgs(req: ServerRequestMessage): Promise<unknown[]> {\n    const args: unknown[] = [];\n    for (const arg of req.Arguments ?? []) {\n      const cancellationRef = asCancellationTokenReference(arg);\n      if (cancellationRef) {\n        // Keyed on the reference's own id, not on the request's CancellationGuid. Those are two\n        // different things: the guid cancels the call, the reference cancels this one parameter.\n        // Registering under the guid meant a cancellation aimed at a parameter never found its\n        // token here, and two token parameters could not be cancelled apart.\n        args.push(this._cancellationManager.create(cancellationRef.Id));\n      } else if (isStreamReference(arg)) {\n        // Download the stream data via HTTP and pass as ArrayBuffer. The endpoint carries the hub's\n        // authorization, so the request has to carry the credential.\n        args.push(await resolveStreamReference(arg, await this._resolveAuthorization()));\n      } else {\n        args.push(arg);\n      }\n    }\n    return args;\n  }\n\n  private async _streamBackToServer(req: ServerRequestMessage, streamId: string): Promise<void> {\n    const args = await this._prepareArgs(req);\n\n    try {\n      // Try stream handler first\n      const streamHandler = this._serverStreamHandlers.get(req.Method);\n      if (streamHandler) {\n        const stream = streamHandler(...args);\n        for await (const item of stream) {\n          await this._hubConnection.send('StreamItemToServer', streamId, item);\n        }\n        await this._hubConnection.send('StreamCompleteToServer', streamId, null);\n        return;\n      }\n\n      // Fall back to regular handler — send single result as one item\n      const handler = this._serverRequestHandlers.get(req.Method);\n      if (handler) {\n        const result = await handler(...args);\n        if (result != null) {\n          // Check if result is async iterable\n          if (typeof result === 'object' && Symbol.asyncIterator in (result as object)) {\n            for await (const item of result as AsyncIterable<unknown>) {\n              await this._hubConnection.send('StreamItemToServer', streamId, item);\n            }\n          } else {\n            await this._hubConnection.send('StreamItemToServer', streamId, result);\n          }\n        }\n        await this._hubConnection.send('StreamCompleteToServer', streamId, null);\n      } else {\n        await this._hubConnection.send('StreamCompleteToServer', streamId, null);\n      }\n    } catch (err) {\n      await this._hubConnection.send('StreamCompleteToServer', streamId, String(err));\n    }\n  }\n\n  private async _uploadAndReturnReference(data: Blob | ArrayBuffer | Uint8Array | unknown): Promise<{ Uri: string }> {\n    // Request an upload URL from the server\n    const uploadUrl = await this._hubConnection.invoke<string>('RequestUploadSlot');\n\n    // Upload the data via HTTP POST\n    let body: BodyInit;\n    if (data instanceof Blob) {\n      body = data;\n    } else if (data instanceof ArrayBuffer || data instanceof Uint8Array) {\n      body = data as BodyInit;\n    } else {\n      body = String(data);\n    }\n    const response = await fetch(uploadUrl, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/octet-stream',\n        ...transferAuthHeaders(await this._resolveAuthorization()),\n      },\n      body,\n    });\n    if (!response.ok) {\n      // Previously the response was discarded, so a rejected upload — 401 from a hub with\n      // [Authorize] being the likely one — produced a stream reference pointing at nothing, and the\n      // failure surfaced much later as an unrelated server-side error.\n      throw new Error(`StreamReference: upload failed (${response.status} ${response.statusText})`);\n    }\n\n    return { Uri: uploadUrl };\n  }\n\n  /** Prepare outgoing arguments — upload binary data and replace with StreamReferences. */\n  private async _prepareOutgoingArgs(args: unknown[]): Promise<unknown[]> {\n    let hasStream = false;\n    for (const arg of args) {\n      if (arg instanceof Blob || arg instanceof ArrayBuffer ||\n          isNodeBuffer(arg)) {\n        hasStream = true;\n        break;\n      }\n    }\n    if (!hasStream) return args;\n\n    const result: unknown[] = [];\n    for (const arg of args) {\n      if (arg instanceof Blob || arg instanceof ArrayBuffer ||\n          isNodeBuffer(arg)) {\n        result.push(await this._uploadAndReturnReference(arg));\n      } else {\n        result.push(arg);\n      }\n    }\n    return result;\n  }\n\n  /**\n   * Connects. A connection the server rejects at negotiate — 401 or 403 for a missing or invalid\n   * connection credential — rejects with SignalR's error, given a `statusCode` with the HTTP status:\n   * SignalR wraps the `HttpError` that had one into an error that only mentions it in the message.\n   */\n  public start(): Promise<void> {\n    return this._hubConnection.start().catch((error: unknown) => {\n      if (error instanceof Error && !('statusCode' in error)) {\n        const status = /Status code '(\\d+)'/.exec(error.message);\n        if (status) {\n          (error as Error & { statusCode?: number }).statusCode = Number(status[1]);\n        }\n      }\n      throw error;\n    });\n  }\n\n  public stop(): Promise<void> {\n    return this._hubConnection.stop();\n  }\n\n  public onClose(callback: (error?: Error) => void): void {\n    this._hubConnection.onclose(callback);\n  }\n\n  public onReconnecting(callback: (error?: Error) => void): void {\n    this._hubConnection.onreconnecting(callback);\n  }\n\n  public onReconnected(callback: (connectionId?: string) => void): void {\n    this._hubConnection.onreconnected(callback);\n  }\n\n  /** Resolves the token factory, sync or async, to the string the message field expects. */\n  private async _resolveAuthorization(): Promise<string> {\n    return (await this._authorization()) ?? '';\n  }\n\n  private async _buildRequest(methodName: string, args: unknown[]): Promise<ClientRequestMessage> {\n    const preparedArgs = await this._prepareOutgoingArgs(args);\n    return {\n      Method: methodName,\n      Arguments: preparedArgs,\n      Authorization: await this._resolveAuthorization(),\n    };\n  }\n\n  public async invoke<T>(methodName: string, ...args: unknown[]): Promise<T> {\n    const msg = await this._buildRequest(methodName, args);\n    return this._hubConnection\n      .invoke<T>('InvokeMessageResult', msg)\n      .catch(err => Promise.reject(this._extractException(err)));\n  }\n\n  public async send(methodName: string, ...args: unknown[]): Promise<void> {\n    const msg = await this._buildRequest(methodName, args);\n    return this._hubConnection.send('SendMessage', msg);\n  }\n\n  /**\n   * `IStreamResult` has to be handed back synchronously, but building the message is asynchronous —\n   * the token has to be awaited, and binary arguments have to be uploaded first, which this path\n   * used to skip entirely. The result is therefore deferred: it starts the real stream once the\n   * message is ready and forwards to whoever subscribed in the meantime.\n   */\n  public stream<T>(methodName: string, ...args: unknown[]): signalR.IStreamResult<T> {\n    const pending = this._buildRequest(methodName, args).then(msg =>\n      this._hubConnection.stream<T>('StreamMessage', msg),\n    );\n    return new DeferredStreamResult<T>(pending);\n  }\n\n  public on(methodName: string, newMethod: (...args: any[]) => void): void {\n    this._hubConnection.on(methodName, newMethod);\n  }\n\n  /** Register a handler for server-to-client method calls (single return value). */\n  public onServerMethod(methodName: string, func: (...args: unknown[]) => unknown): this {\n    this._serverRequestHandlers.set(methodName, func);\n    return this;\n  }\n\n  /** Register a handler for server-to-client streaming calls (returns AsyncIterable). */\n  public onServerStreamMethod(methodName: string, func: (...args: unknown[]) => AsyncIterable<unknown>): this {\n    this._serverStreamHandlers.set(methodName, func);\n    return this;\n  }\n\n  public off(methodName: string): void;\n  public off(methodName: string, method: (...args: any[]) => void): void;\n  public off(methodName: string, method?: (...args: any[]) => void): void {\n    if (!method) {\n      this._hubConnection.off(methodName);\n    } else {\n      this._hubConnection.off(methodName, method);\n    }\n  }\n\n  public asSignalRHubConnection(): signalR.HubConnection {\n    return this._hubConnection;\n  }\n\n  /**\n   * Creates a connection to a hub URL. SignalARRR builds the SignalR connection itself, so the\n   * connection credential (`credential` or `connectionCredential`) can be applied — it becomes\n   * SignalR's `accessTokenFactory`. `configure` gets the builder after `withUrl`, for the protocol,\n   * automatic reconnect, logging and the like.\n   */\n  public static create(\n    url: string,\n    options?: HARRRConnectionOptions,\n    configure?: (builder: signalR.HubConnectionBuilder) => void,\n  ): HARRRConnection;\n  /** Wraps a `HubConnection`, or builds one through the callback. Only the message credential applies. */\n  public static create(\n    hubConnection: signalR.HubConnection | ((builder: signalR.HubConnectionBuilder) => void),\n    options?: HARRRConnectionOptions,\n  ): HARRRConnection;\n  public static create(\n    hubConnection: string | signalR.HubConnection | ((builder: signalR.HubConnectionBuilder) => void),\n    options?: HARRRConnectionOptions,\n    configure?: (builder: signalR.HubConnectionBuilder) => void,\n  ): HARRRConnection {\n    if (typeof hubConnection === 'string') {\n      const messageCredential = resolveMessageCredential(options);\n      const connectionCredential = resolveConnectionCredential(options);\n      const httpOptions: signalR.IHttpConnectionOptions = { ...options?.httpConnectionOptions };\n      if (connectionCredential !== undefined) {\n        if (httpOptions.accessTokenFactory) {\n          throw new Error(\n            \"The connection credential is set twice: through httpConnectionOptions.accessTokenFactory and through connectionCredential/credential. Set only one of them.\",\n          );\n        }\n        httpOptions.accessTokenFactory = credentialFactory(connectionCredential);\n      }\n      const builder = new signalR.HubConnectionBuilder().withUrl(hubConnection, httpOptions);\n      configure?.(builder);\n      // The connection credential is consumed here; the connection itself only takes the message one.\n      return new HARRRConnection(builder.build(), { messageCredential });\n    }\n    if (hubConnection instanceof Function) {\n      const builder = new signalR.HubConnectionBuilder();\n      hubConnection(builder);\n      return new HARRRConnection(builder.build(), options);\n    }\n    return new HARRRConnection(hubConnection, options);\n  }\n\n  private _extractException(error: unknown): HARRRInvocationError {\n    const parsed = parseHARRRError(error);\n    return {\n      type: parsed.Type,\n      message: parsed.Message,\n      code: parsed.Code,\n      normalizedCode: normalizeErrorCode(parsed.Code),\n    };\n  }\n}\n\n/**\n * An `IStreamResult` whose underlying stream is not open yet.\n *\n * Subscribers registered before the stream exists are attached as soon as it does; a failure while\n * preparing the message — a rejecting token factory, a failed upload — reaches them through\n * `error()` rather than being thrown out of `stream()`, which is where a caller can observe it.\n * Disposing before the stream opens means it is never subscribed to at all.\n */\nclass DeferredStreamResult<T> implements signalR.IStreamResult<T> {\n  constructor(private readonly _pending: Promise<signalR.IStreamResult<T>>) {\n    // The rejection is delivered to subscribers below. This keeps it from also counting as an\n    // unhandled rejection when nobody subscribes, which in Node terminates the process.\n    this._pending.catch(() => undefined);\n  }\n\n  public subscribe(subscriber: signalR.IStreamSubscriber<T>): signalR.ISubscription<T> {\n    let inner: signalR.ISubscription<T> | undefined;\n    let disposed = false;\n\n    this._pending.then(\n      stream => {\n        if (disposed) return;\n        inner = stream.subscribe(subscriber);\n      },\n      err => {\n        if (disposed) return;\n        subscriber.error(err);\n      },\n    );\n\n    return {\n      dispose: () => {\n        disposed = true;\n        inner?.dispose();\n      },\n    };\n  }\n}\n\n/** Runtime check for Node.js Buffer without importing @types/node */\nfunction isNodeBuffer(value: unknown): boolean {\n  return typeof globalThis !== 'undefined' &&\n    typeof (globalThis as Record<string, unknown>)['Buffer'] === 'function' &&\n    typeof ((globalThis as Record<string, unknown>)['Buffer'] as Record<string, unknown>)['isBuffer'] === 'function' &&\n    ((globalThis as Record<string, unknown>)['Buffer'] as { isBuffer: (v: unknown) => boolean }).isBuffer(value);\n}\n","/**\n * The `__type` marker the server puts on arguments that are handles rather than values.\n *\n * Some arguments are not data but references: a cancellation token the server can trip later, a\n * stream the client has to fetch. The client has to recognise them to swap them back, and it used\n * to do that by guessing from the shape. Guessing is wrong on ordinary data that happens to look\n * the same — a payload with a lone string `Id` was silently replaced by a cancellation token. The\n * .NET clients never had the problem because they know the parameter types; this one does not.\n */\nexport const REMOTE_REFERENCE_PROPERTY = '__type';\n\nexport const RemoteReferenceKind = {\n  CancellationToken: 'cancellationToken',\n  Stream: 'stream',\n} as const;\n\nexport type RemoteReferenceKind = (typeof RemoteReferenceKind)[keyof typeof RemoteReferenceKind];\n\n/** Whether the value carries the marker at all, regardless of which kind it names. */\nexport function isRemoteReference(v: unknown): v is Record<string, unknown> {\n  return (\n    typeof v === 'object' &&\n    v !== null &&\n    typeof (v as Record<string, unknown>)[REMOTE_REFERENCE_PROPERTY] === 'string'\n  );\n}\n","import { REMOTE_REFERENCE_PROPERTY, RemoteReferenceKind, isRemoteReference } from './remote-reference.js';\n\nexport interface CancellationTokenReference {\n  Id: string;\n}\n\nconst GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * Recognises an argument the server sent in place of a cancellation token.\n *\n * The `__type` marker is exact and is preferred. Everything below it is a fallback for a server\n * that does not send the marker yet, and it is deliberately strict: the previous check accepted\n * *any* object carrying a string `Id`, so an ordinary payload such as\n * `{ Id: \"user-42\", Name: \"Ada\" }` was swapped for a cancellation token and never reached the\n * handler. Requiring a lone, GUID-shaped `Id` makes that collision unlikely — only the marker\n * rules it out.\n */\nexport function asCancellationTokenReference(v: unknown): CancellationTokenReference | undefined {\n  if (typeof v !== 'object' || v === null) return undefined;\n\n  const obj = v as Record<string, unknown>;\n  const id = obj['Id'];\n  if (typeof id !== 'string') return undefined;\n\n  if (isRemoteReference(obj)) {\n    return obj[REMOTE_REFERENCE_PROPERTY] === RemoteReferenceKind.CancellationToken ? { Id: id } : undefined;\n  }\n\n  return Object.keys(obj).length === 1 && GUID.test(id) ? { Id: id } : undefined;\n}\n\n/** @deprecated Prefer {@link asCancellationTokenReference}; this cannot return the id. */\nexport function isCancellationTokenReference(v: unknown): v is CancellationTokenReference {\n  return asCancellationTokenReference(v) !== undefined;\n}\n","import { REMOTE_REFERENCE_PROPERTY, RemoteReferenceKind, isRemoteReference } from './remote-reference.js';\n\nexport interface StreamReference {\n  Uri: string;\n}\n\n/**\n * Recognises an argument the server sent in place of a stream.\n *\n * The `__type` marker is exact and is preferred; the lone-`Uri` check below it is the fallback for\n * a server that does not send the marker yet. Note that the fallback must not simply count keys any\n * more: a marked reference has two, and rejecting it on that basis is how adding the marker would\n * have broken stream arguments outright.\n */\nexport function isStreamReference(v: unknown): v is StreamReference {\n  if (typeof v !== 'object' || v === null) return false;\n\n  const obj = v as Record<string, unknown>;\n  if (typeof obj['Uri'] !== 'string') return false;\n\n  if (isRemoteReference(obj)) {\n    return obj[REMOTE_REFERENCE_PROPERTY] === RemoteReferenceKind.Stream;\n  }\n\n  return Object.keys(obj).length === 1;\n}\n\n/**\n * Builds the `Authorization` header for a file-transfer request.\n *\n * `/download/{id}` and `/upload/{id}` are ordinary HTTP endpoints: they carry the hub's\n * authorization requirements but not its connection, so nothing authenticates them unless the\n * request does. A bare `fetch` meant a hub with `[Authorize]` answered 401 to every stream argument\n * and every stream return value.\n *\n * The `Bearer` convention matches the server's: a credential without a space is a bearer token, one\n * with a space carries its own scheme.\n */\nexport function transferAuthHeaders(authorization?: string): Record<string, string> {\n  if (!authorization) return {};\n  return { Authorization: authorization.includes(' ') ? authorization : `Bearer ${authorization}` };\n}\n\n/** Resolve a StreamReference by downloading the data — returns the full content buffered in memory. */\nexport async function resolveStreamReference(ref: StreamReference, authorization?: string): Promise<ArrayBuffer> {\n  const response = await fetchStreamReference(ref, authorization);\n  return response.arrayBuffer();\n}\n\n/** Resolve a StreamReference as a ReadableStream — for large files, avoids buffering in memory. */\nexport async function resolveStreamReferenceAsStream(\n  ref: StreamReference,\n  authorization?: string,\n): Promise<ReadableStream<Uint8Array>> {\n  const response = await fetchStreamReference(ref, authorization);\n  if (!response.body) {\n    throw new Error('StreamReference: response has no body stream');\n  }\n  return response.body;\n}\n\nasync function fetchStreamReference(ref: StreamReference, authorization?: string): Promise<Response> {\n  const url = ref.Uri;\n  const scheme = url.split(':')[0]?.toLowerCase();\n  if (scheme !== 'http' && scheme !== 'https') {\n    throw new Error(`StreamReference: unsupported URI scheme '${scheme}'`);\n  }\n  const response = await fetch(url, { headers: transferAuthHeaders(authorization) });\n  if (!response.ok) {\n    throw new Error(`StreamReference: download failed (${response.status} ${response.statusText})`);\n  }\n  return response;\n}\n","/**\n * The machine-readable error codes of the wire contract — the same set as `HARRRErrorCodes` in the\n * .NET, Swift and Kotlin clients. Branch on these: a code is the only cross-language signal, a .NET\n * type name means nothing here. Application code may put its own codes on the wire\n * (`HARRRException(\"room_full\", ...)` on the server); those travel verbatim in `code`, while\n * `normalizedCode` folds anything this client does not know to `internal`.\n */\nexport const HARRRErrorCodes = {\n  /** Authorization rejected the call. */\n  Unauthorized: 'unauthorized',\n  /** No method (or interface) is registered under the requested name. */\n  MethodNotFound: 'method_not_found',\n  /** The name exists, but no registered method accepts this argument count. */\n  InvalidArgumentCount: 'invalid_argument_count',\n  /** An argument could not be deserialized or coerced to the parameter type. */\n  ArgumentBindingFailed: 'argument_binding_failed',\n  /** The call was cancelled — an expected outcome, not a failure. */\n  Cancelled: 'cancelled',\n  /** A server-side deadline expired (e.g. waiting for a stream upload). */\n  Timeout: 'timeout',\n  /** No client answered the invoke (locally or across the backplane). */\n  NoClientResponded: 'no_client_responded',\n  /** The connection already holds as many unused upload slots as it is allowed to. */\n  UploadSlotLimitReached: 'upload_slot_limit_reached',\n  /** The invoked method itself threw — the default bucket. */\n  Internal: 'internal',\n} as const;\n\nconst knownCodes: ReadonlySet<string> = new Set(Object.values(HARRRErrorCodes));\n\n/** Maps a wire code to one this client knows; unknown or missing codes become `internal`. */\nexport function normalizeErrorCode(code: string | undefined | null): string {\n  return code != null && knownCodes.has(code) ? code : HARRRErrorCodes.Internal;\n}\n\n/**\n * Structured error envelope from SignalARRR server exceptions.\n * The server serializes exceptions as JSON in the HubException message string.\n */\nexport interface HARRRError {\n  /** Envelope version; 1 and up carry `Code`. */\n  Version?: number;\n  /** The machine-readable code — see `HARRRErrorCodes`. */\n  Code?: string;\n  /** The .NET exception type, for diagnostics. */\n  Type: string;\n  Message: string;\n  StackTrace?: string;\n  InnerError?: HARRRError;\n}\n\n/**\n * What `invoke()` rejects with when the server returns an error. `code` is what to branch on —\n * compare `normalizedCode` against `HARRRErrorCodes`; `message` is for humans; `type` is the .NET\n * exception type.\n */\nexport interface HARRRInvocationError {\n  type: string;\n  message: string;\n  /** The code as sent, including application-defined codes; `undefined` from an older server. */\n  code: string | undefined;\n  /** `code` folded to one of `HARRRErrorCodes`; unknown or missing codes become `internal`. */\n  normalizedCode: string;\n}\n\n/**\n * Parse a HubException message into a structured HARRRError.\n * Supports both the new JSON format and the legacy `[Type] Message` format.\n *\n * SignalR wraps HubException messages with prefix text like:\n * \"An unexpected error occurred invoking '...' on the server. HARRRException: {json}\"\n */\nexport function parseHARRRError(error: unknown): HARRRError {\n  const msg = error instanceof Error ? error.message : String(error);\n\n  // Extract JSON after \"HARRRException: \" marker (SignalR wrapping)\n  const marker = 'HARRRException: ';\n  const markerIndex = msg.indexOf(marker);\n  const jsonCandidate = markerIndex >= 0 ? msg.substring(markerIndex + marker.length) : msg;\n\n  // Try JSON format. Accepted when it carries actual error content — a versioned envelope, a code,\n  // or a type and message — the same test as the .NET and Kotlin clients, plus the Type/Message\n  // shape this client always accepted.\n  try {\n    const parsed = JSON.parse(jsonCandidate);\n    if (typeof parsed === 'object' && parsed !== null) {\n      const versioned = typeof parsed.Version === 'number' && parsed.Version >= 1;\n      const coded = typeof parsed.Code === 'string' && parsed.Code.length > 0;\n      const typed = typeof parsed.Type === 'string' && typeof parsed.Message === 'string';\n      if (versioned || coded || typed) {\n        return {\n          ...parsed,\n          Type: typeof parsed.Type === 'string' && parsed.Type.length > 0 ? parsed.Type : 'Error',\n          Message: typeof parsed.Message === 'string' ? parsed.Message : '',\n        } as HARRRError;\n      }\n    }\n  } catch {\n    // Not JSON — try legacy format\n  }\n\n  // Legacy format: [Type] Message\n  const matches = /\\[([\\w.]+)\\]\\s*(.*)/m.exec(msg);\n  if (matches) {\n    return {\n      Type: matches[1] ?? 'Error',\n      Message: matches[2] ?? msg,\n    };\n  }\n\n  // Fallback\n  return {\n    Type: 'Error',\n    Message: msg,\n  };\n}\n","import type * as signalR from '@microsoft/signalr';\n\n/** A credential: a fixed value, or a function called whenever the credential is needed. */\nexport type Credential = string | (() => string | Promise<string>);\n\n/**\n * SignalARRR's options for a connection.\n *\n * A connection has two credentials, checked by different things. The **connection credential**\n * authenticates negotiate and the transport and is what `[Authorize]` on the hub class checks. The\n * **message credential** travels with every message, answers authentication challenges and\n * authenticates file transfers, and is what `[Authorize]` on a method or a `ServerMethods` class\n * checks. The options are named the same in every SignalARRR client, and nothing is coupled\n * implicitly: setting one of the two sets only that one.\n */\nexport class HARRRConnectionOptions {\n  /**\n   * One credential for the connection and for every message — the common case. A\n   * `connectionCredential` or `messageCredential` set alongside it takes its part over.\n   */\n  public credential?: Credential;\n\n  /**\n   * Authenticates the connection: the negotiate request and the transport. Becomes SignalR's\n   * `accessTokenFactory`, so it is called on every connect and reconnect. Only available through\n   * `HARRRConnection.create(url, options)`; a `HubConnection` that is already built has its own.\n   */\n  public connectionCredential?: Credential;\n\n  /**\n   * The credential SignalARRR sends with every message, as the answer to an authentication\n   * challenge, and on file-transfer requests. Resolved per use, so a refreshed token is picked up.\n   */\n  public messageCredential?: Credential;\n\n  /**\n   * SignalR's own connection options for `HARRRConnection.create(url, options)` — transport,\n   * headers, `withCredentials` and the like. Set the connection credential through\n   * `connectionCredential` or `credential`, not through `accessTokenFactory` here.\n   */\n  public httpConnectionOptions?: signalR.IHttpConnectionOptions;\n\n  /**\n   * The message credential under its former name.\n   *\n   * SignalARRR used to adopt SignalR's factory by reading private fields off the connection, so the\n   * two could never be told apart, and a credential meant for the connection alone — a single-use\n   * ticket, say — was resent with every message. Nothing is adopted now: a connection that\n   * authenticates per message has to say so, or the server will challenge it for a credential it\n   * never sends once the auth cache expires.\n   *\n   * @deprecated Use `messageCredential`, or `credential` for one credential covering the connection\n   * and every message.\n   */\n  public authorization?: Credential;\n}\n\n/** Turns a credential option into the function SignalARRR and SignalR call. */\nexport function credentialFactory(credential: Credential): () => string | Promise<string> {\n  return typeof credential === 'function' ? credential : () => credential;\n}\n\n/** The message credential in effect, after checking that the old and the new option are not both set. */\nexport function resolveMessageCredential(options?: HARRRConnectionOptions): Credential | undefined {\n  // The former option is still honoured.\n  const legacy = options?.authorization;\n  const current = options?.messageCredential ?? options?.credential;\n  if (legacy !== undefined && current !== undefined) {\n    throw new Error(\n      'Both authorization and messageCredential/credential are set. authorization is the former name of messageCredential; set only messageCredential (or credential).',\n    );\n  }\n  return legacy ?? current;\n}\n\n/** The connection credential in effect. */\nexport function resolveConnectionCredential(options?: HARRRConnectionOptions): Credential | undefined {\n  return options?.connectionCredential ?? options?.credential;\n}\n","export class CancellationManager {\n  private _controllers = new Map<string, AbortController>();\n\n  create(id: string): AbortSignal {\n    const controller = new AbortController();\n    this._controllers.set(id, controller);\n    return controller.signal;\n  }\n\n  cancel(id: string): void {\n    const controller = this._controllers.get(id);\n    if (controller) {\n      controller.abort();\n      this._controllers.delete(id);\n    }\n  }\n\n  remove(id: string): void {\n    this._controllers.delete(id);\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,cAAyB;;;ACSlB,IAAM,4BAA4B;AAElC,IAAM,sBAAsB;AAAA,EACjC,mBAAmB;AAAA,EACnB,QAAQ;AACV;AAKO,SAAS,kBAAkB,GAA0C;AAC1E,SACE,OAAO,MAAM,YACb,MAAM,QACN,OAAQ,EAA8B,yBAAyB,MAAM;AAEzE;;;ACnBA,IAAM,OAAO;AAYN,SAAS,6BAA6B,GAAoD;AAC/F,MAAI,OAAO,MAAM,YAAY,MAAM,KAAM,QAAO;AAEhD,QAAM,MAAM;AACZ,QAAM,KAAK,IAAI,IAAI;AACnB,MAAI,OAAO,OAAO,SAAU,QAAO;AAEnC,MAAI,kBAAkB,GAAG,GAAG;AAC1B,WAAO,IAAI,yBAAyB,MAAM,oBAAoB,oBAAoB,EAAE,IAAI,GAAG,IAAI;AAAA,EACjG;AAEA,SAAO,OAAO,KAAK,GAAG,EAAE,WAAW,KAAK,KAAK,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;AACvE;;;AChBO,SAAS,kBAAkB,GAAkC;AA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