@securitydept/client 0.3.0-beta.3 → 0.3.0-beta.5

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 (58) hide show
  1. package/README.md +6 -0
  2. package/dist/create-Bm-XRA3G.mjs +1573 -0
  3. package/dist/create-Bm-XRA3G.mjs.map +1 -0
  4. package/dist/index-BT-u3qNI.d.mts +133 -0
  5. package/dist/index-Ch8lrE44.d.mts +625 -0
  6. package/dist/index-D5mW18cM.d.mts +1648 -0
  7. package/dist/index.d.mts +3 -353
  8. package/dist/index.mjs +1124 -362
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/router-BJ8LqNJ1.mjs +245 -0
  11. package/dist/router-BJ8LqNJ1.mjs.map +1 -0
  12. package/dist/rx/index.d.mts +69 -0
  13. package/dist/rx/index.mjs +2 -0
  14. package/dist/rx-BoB32Dzg.mjs +1106 -0
  15. package/dist/rx-BoB32Dzg.mjs.map +1 -0
  16. package/dist/server/index.d.mts +21 -0
  17. package/dist/server/index.mjs +29 -0
  18. package/dist/server/index.mjs.map +1 -0
  19. package/dist/test/index.d.mts +102 -0
  20. package/dist/test/index.mjs +270 -0
  21. package/dist/test/index.mjs.map +1 -0
  22. package/dist/uri-string-BfnIT4gJ.mjs +298 -0
  23. package/dist/uri-string-BfnIT4gJ.mjs.map +1 -0
  24. package/dist/web/index.d.mts +82 -364
  25. package/dist/web/index.mjs +329 -428
  26. package/dist/web/index.mjs.map +1 -1
  27. package/dist/webext/index.d.mts +74 -0
  28. package/dist/webext/index.mjs +229 -0
  29. package/dist/webext/index.mjs.map +1 -0
  30. package/package.json +28 -21
  31. package/dist/auth-coordination/index.d.mts +0 -198
  32. package/dist/auth-coordination/index.mjs +0 -107
  33. package/dist/auth-coordination/index.mjs.map +0 -1
  34. package/dist/client-environment-CaumNmir.mjs +0 -812
  35. package/dist/client-environment-CaumNmir.mjs.map +0 -1
  36. package/dist/client-environment-CdHtVxKW.d.mts +0 -401
  37. package/dist/events/index.d.mts +0 -2
  38. package/dist/events/index.mjs +0 -2
  39. package/dist/events-BUlfsRfl.mjs +0 -127
  40. package/dist/events-BUlfsRfl.mjs.map +0 -1
  41. package/dist/index-C4xlKhG7.d.mts +0 -102
  42. package/dist/index-COUt5x9Z.d.mts +0 -39
  43. package/dist/persistence/index.d.mts +0 -3
  44. package/dist/persistence/index.mjs +0 -2
  45. package/dist/persistence/web/index.d.mts +0 -16
  46. package/dist/persistence/web/index.mjs +0 -2
  47. package/dist/persistence-CSB8770k.mjs +0 -108
  48. package/dist/persistence-CSB8770k.mjs.map +0 -1
  49. package/dist/planner-host-BTWie0lo.mjs +0 -197
  50. package/dist/planner-host-BTWie0lo.mjs.map +0 -1
  51. package/dist/planner-host-DN9dRsQx.d.mts +0 -190
  52. package/dist/types-BJqUdH2e.d.mts +0 -32
  53. package/dist/types-BwcnUGNl.d.mts +0 -52
  54. package/dist/web-DQmMqZnR.mjs +0 -51
  55. package/dist/web-DQmMqZnR.mjs.map +0 -1
  56. package/dist/web-router/index.d.mts +0 -259
  57. package/dist/web-router/index.mjs +0 -395
  58. package/dist/web-router/index.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-environment-CaumNmir.mjs","names":[],"sources":["../src/errors/types.ts","../src/errors/client-error.ts","../src/logging/types.ts","../src/logging/operation-tracer.ts","../src/scheduling/default-clock.ts","../src/scheduling/default-scheduler.ts","../src/runtime/create-runtime.ts","../src/scheduling/helpers.ts","../src/web/input-sources.ts","../src/web/cancellation.ts","../src/transport/fetch-transport.ts","../src/web/runtime.ts","../src/web/client-environment.ts"],"sourcesContent":["// --- Error model ---\n// Dual-layer: machine-facing runtime error + user-facing presentation / recovery hint.\n\n/** Recovery actions the user might take. Aligned with server-side `UserRecovery`. */\nexport const UserRecovery = {\n\tNone: \"none\",\n\tRetry: \"retry\",\n\tRestartFlow: \"restart_flow\",\n\tReauthenticate: \"reauthenticate\",\n\tContactSupport: \"contact_support\",\n} as const;\n\nexport type UserRecovery = (typeof UserRecovery)[keyof typeof UserRecovery];\n\n/** User-facing error presentation. `code` is the cross-platform stable contract. */\nexport interface ErrorPresentation {\n\tcode: string;\n\tmessage: string;\n\trecovery: UserRecovery;\n}\n\nexport const ErrorPresentationTone = {\n\tNeutral: \"neutral\",\n\tWarning: \"warning\",\n\tDanger: \"danger\",\n} as const;\n\nexport type ErrorPresentationTone =\n\t(typeof ErrorPresentationTone)[keyof typeof ErrorPresentationTone];\n\nexport interface ErrorPresentationActionDescriptor {\n\trecovery: UserRecovery;\n\tlabel: string;\n\thref: string | null;\n}\n\nexport interface ErrorPresentationDescriptor {\n\tcode: string | null;\n\tkind: ClientErrorKind | null;\n\tsource?: string;\n\ttitle: string;\n\tdescription: string;\n\trecovery: UserRecovery;\n\tretryable: boolean;\n\ttone: ErrorPresentationTone;\n\tprimaryAction: ErrorPresentationActionDescriptor | null;\n}\n\nexport interface ReadErrorPresentationDescriptorOptions {\n\tfallbackTitle?: string;\n\tfallbackDescription?: string;\n\trecoveryLinks?: Partial<Record<UserRecovery, string>>;\n\trecoveryLabels?: Partial<Record<UserRecovery, string>>;\n}\n\n/** Machine-facing error kind discriminator. */\nexport const ClientErrorKind = {\n\tAuthorization: \"authorization\",\n\tTransport: \"transport\",\n\tServer: \"server\",\n\tProtocol: \"protocol\",\n\tPresentation: \"presentation\",\n\tValidation: \"validation\",\n\tStorage: \"storage\",\n\tScheduler: \"scheduler\",\n\tConfiguration: \"configuration\",\n\tUnauthenticated: \"unauthenticated\",\n\tUnauthorized: \"unauthorized\",\n\tRedirectRequired: \"redirect_required\",\n\tCancelled: \"cancelled\",\n\tTimeout: \"timeout\",\n\tInternal: \"internal\",\n} as const;\n\nexport type ClientErrorKind =\n\t(typeof ClientErrorKind)[keyof typeof ClientErrorKind];\n\n/** Stable source vocabulary for common client error producers. */\nexport const ClientErrorSource = {\n\tTransport: \"transport\",\n\tServer: \"server\",\n\tClientEnvironment: \"client_environment\",\n} as const;\n\nexport type ClientErrorSource =\n\t(typeof ClientErrorSource)[keyof typeof ClientErrorSource];\n","import {\n\tClientErrorKind,\n\tClientErrorSource,\n\ttype ErrorPresentation,\n\tUserRecovery,\n\ttype UserRecovery as UserRecoveryType,\n} from \"./types\";\n\ntype ServerErrorBody = {\n\tkind?: string;\n\tcode?: string;\n\tmessage?: string;\n\trecovery?: string;\n\tpresentation?: {\n\t\tcode?: string;\n\t\tmessage?: string;\n\t\trecovery?: string;\n\t};\n};\n\nfunction mapServerErrorKind(\n\tkind: string | undefined,\n\tstatus: number,\n): ClientErrorKind {\n\tswitch (kind) {\n\t\tcase \"unauthenticated\":\n\t\t\treturn ClientErrorKind.Unauthenticated;\n\t\tcase \"unauthorized\":\n\t\t\treturn ClientErrorKind.Unauthorized;\n\t\tcase \"unavailable\":\n\t\tcase \"internal\":\n\t\t\treturn ClientErrorKind.Server;\n\t\tcase \"invalid_request\":\n\t\tcase \"conflict\":\n\t\t\treturn ClientErrorKind.Protocol;\n\t\tdefault:\n\t\t\treturn status === 401\n\t\t\t\t? ClientErrorKind.Unauthenticated\n\t\t\t\t: status === 403\n\t\t\t\t\t? ClientErrorKind.Unauthorized\n\t\t\t\t\t: status >= 500\n\t\t\t\t\t\t? ClientErrorKind.Server\n\t\t\t\t\t\t: ClientErrorKind.Protocol;\n\t}\n}\n\nfunction readServerErrorBody(body: unknown): ServerErrorBody | undefined {\n\tif (!body || typeof body !== \"object\") return undefined;\n\tconst record = body as Record<string, unknown>;\n\tconst error =\n\t\trecord.error && typeof record.error === \"object\"\n\t\t\t? (record.error as Record<string, unknown>)\n\t\t\t: record;\n\n\treturn {\n\t\tkind: typeof error.kind === \"string\" ? error.kind : undefined,\n\t\tcode: typeof error.code === \"string\" ? error.code : undefined,\n\t\tmessage: typeof error.message === \"string\" ? error.message : undefined,\n\t\trecovery: typeof error.recovery === \"string\" ? error.recovery : undefined,\n\t\tpresentation:\n\t\t\terror.presentation && typeof error.presentation === \"object\"\n\t\t\t\t? {\n\t\t\t\t\t\tcode:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>).code ===\n\t\t\t\t\t\t\t\"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.code as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>).message ===\n\t\t\t\t\t\t\t\"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.message as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trecovery:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t.recovery === \"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.recovery as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t};\n}\n\n/**\n * Base client error carrying both machine-facing context and an optional\n * user-facing presentation layer.\n *\n * Top-level `code` and `recovery` provide stable machine contracts for\n * policy decisions without requiring callers to unwrap `presentation`.\n */\nexport class ClientError extends Error {\n\treadonly kind: ClientErrorKind;\n\n\t/**\n\t * Stable machine-readable error code.\n\t * Matches `presentation.code` when present, otherwise a default\n\t * derived from `kind`.\n\t */\n\treadonly code: string;\n\n\t/** Recovery hint at the machine level. */\n\treadonly recovery: UserRecoveryType;\n\n\t/** Whether this error is safe to retry. */\n\treadonly retryable: boolean;\n\n\t/** Structured user-facing error presentation from the server. */\n\treadonly presentation?: ErrorPresentation;\n\n\t/** Source subsystem or component that produced the error. */\n\treadonly source?: string;\n\n\tconstructor(options: {\n\t\tkind: ClientErrorKind;\n\t\tmessage: string;\n\t\tcode?: string;\n\t\trecovery?: UserRecoveryType;\n\t\tretryable?: boolean;\n\t\tpresentation?: ErrorPresentation;\n\t\tsource?: string;\n\t\tcause?: unknown;\n\t}) {\n\t\tsuper(options.message, { cause: options.cause });\n\t\tthis.name = \"ClientError\";\n\t\tthis.kind = options.kind;\n\t\tthis.code =\n\t\t\toptions.code ?? options.presentation?.code ?? `client.${options.kind}`;\n\t\tthis.recovery =\n\t\t\toptions.recovery ?? options.presentation?.recovery ?? UserRecovery.None;\n\t\tthis.retryable = options.retryable ?? this.recovery === UserRecovery.Retry;\n\t\tthis.presentation = options.presentation;\n\t\tthis.source = options.source;\n\t}\n\n\t/** Create a `ClientError` from a server error response body. */\n\tstatic fromServerError(\n\t\tbody: {\n\t\t\tkind?: string;\n\t\t\tcode?: string;\n\t\t\tmessage?: string;\n\t\t\trecovery?: string;\n\t\t\tpresentation?: {\n\t\t\t\tcode?: string;\n\t\t\t\tmessage?: string;\n\t\t\t\trecovery?: string;\n\t\t\t};\n\t\t},\n\t\toverrides?: { kind?: ClientErrorKind; source?: string },\n\t): ClientError {\n\t\tconst rawPresentation = body.presentation;\n\t\tconst presentation: ErrorPresentation | undefined =\n\t\t\t(rawPresentation?.code ?? body.code) &&\n\t\t\t(rawPresentation?.message ?? body.message)\n\t\t\t\t? {\n\t\t\t\t\t\tcode: rawPresentation?.code ?? body.code ?? \"unknown_server_error\",\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\trawPresentation?.message ??\n\t\t\t\t\t\t\tbody.message ??\n\t\t\t\t\t\t\t\"Unknown server error\",\n\t\t\t\t\t\trecovery:\n\t\t\t\t\t\t\t(rawPresentation?.recovery as ErrorPresentation[\"recovery\"]) ??\n\t\t\t\t\t\t\t(body.recovery as ErrorPresentation[\"recovery\"]) ??\n\t\t\t\t\t\t\tUserRecovery.None,\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\treturn new ClientError({\n\t\t\tkind: overrides?.kind ?? mapServerErrorKind(body.kind, 400),\n\t\t\tmessage: presentation?.message ?? body.message ?? \"Unknown server error\",\n\t\t\tpresentation,\n\t\t\tsource: overrides?.source,\n\t\t});\n\t}\n\n\t/**\n\t * Create a `ClientError` from an HTTP response status and optional body.\n\t * Used when a non-success status is unexpected.\n\t */\n\tstatic fromHttpResponse(status: number, body?: unknown): ClientError {\n\t\tconst serverBody = readServerErrorBody(body);\n\n\t\t// Derive kind and source from HTTP status first — these apply\n\t\t// whether or not the response carries a structured error body.\n\t\tconst kind = mapServerErrorKind(serverBody?.kind, status);\n\n\t\tconst source =\n\t\t\tstatus >= 500\n\t\t\t\t? ClientErrorSource.Server\n\t\t\t\t: ClientErrorSource.ClientEnvironment;\n\n\t\t// If the server returned a structured error body, preserve it\n\t\t// but keep the status-derived kind/source.\n\t\tif (serverBody?.code && serverBody?.message) {\n\t\t\treturn ClientError.fromServerError(serverBody, { kind, source });\n\t\t}\n\n\t\tconst recovery: UserRecoveryType =\n\t\t\tkind === ClientErrorKind.Unauthenticated\n\t\t\t\t? UserRecovery.Reauthenticate\n\t\t\t\t: status >= 500\n\t\t\t\t\t? UserRecovery.Retry\n\t\t\t\t\t: UserRecovery.None;\n\n\t\treturn new ClientError({\n\t\t\tkind,\n\t\t\tmessage: serverBody?.message ?? `HTTP ${status}`,\n\t\t\tcode: serverBody?.code ?? `http.${status}`,\n\t\t\trecovery,\n\t\t\tretryable: status >= 500,\n\t\t\tsource,\n\t\t});\n\t}\n}\n","// --- Logging and observability ---\n\nexport const LogLevel = {\n\tDebug: \"debug\",\n\tInfo: \"info\",\n\tWarn: \"warn\",\n\tError: \"error\",\n} as const;\n\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];\n\nexport interface LogEntry {\n\tlevel: LogLevel;\n\tmessage: string;\n\tscope?: string;\n\tcode?: string;\n\tattributes?: Record<string, unknown>;\n\terror?: unknown;\n\tat?: number;\n}\n\nexport interface LoggerTrait {\n\tlog(entry: LogEntry): void;\n}\n\nexport const OperationTraceEventType = {\n\tStarted: \"operation.started\",\n\tEvent: \"operation.event\",\n\tError: \"operation.error\",\n\tEnded: \"operation.ended\",\n} as const;\n\nexport type OperationTraceEventType =\n\t(typeof OperationTraceEventType)[keyof typeof OperationTraceEventType];\n\nexport interface TraceEvent {\n\ttype: string;\n\tat: number;\n\tscope?: string;\n\toperationId?: string;\n\tsource?: string;\n\tattributes?: Record<string, unknown>;\n}\n\nexport interface TraceEventSinkTrait {\n\trecord(event: TraceEvent): void;\n}\n\nexport interface OperationScope {\n\tid: string;\n\taddEvent(type: string, attributes?: Record<string, unknown>): void;\n\tsetAttribute(key: string, value: unknown): void;\n\trecordError(error: unknown, attributes?: Record<string, unknown>): void;\n\tend(attributes?: Record<string, unknown>): void;\n}\n\nexport interface OperationTracerTrait {\n\tstartOperation(\n\t\tname: string,\n\t\tattributes?: Record<string, unknown>,\n\t): OperationScope;\n}\n","import type { Clock } from \"../scheduling/types\";\nimport type {\n\tLoggerTrait,\n\tOperationScope,\n\tOperationTracerTrait,\n\tTraceEventSinkTrait,\n} from \"./types\";\nimport { LogLevel, OperationTraceEventType } from \"./types\";\n\nexport interface CreateOperationTracerOptions {\n\ttraceSink?: TraceEventSinkTrait;\n\tlogger?: LoggerTrait;\n\tclock?: Clock;\n\tscope?: string;\n\tsource?: string;\n\tidFactory?: () => string;\n}\n\nconst defaultClock: Clock = {\n\tnow: () => Date.now(),\n};\n\nfunction createDefaultOperationId(): string {\n\treturn `op_${Math.random().toString(36).slice(2, 10)}`;\n}\n\nclass DefaultOperationScope implements OperationScope {\n\treadonly id: string;\n\n\tprivate readonly _attributes: Record<string, unknown>;\n\tprivate _ended = false;\n\n\tconstructor(\n\t\tprivate readonly _name: string,\n\t\tprivate readonly _clock: Clock,\n\t\tprivate readonly _traceSink: TraceEventSinkTrait | undefined,\n\t\tprivate readonly _logger: LoggerTrait | undefined,\n\t\tprivate readonly _scope: string | undefined,\n\t\tprivate readonly _source: string | undefined,\n\t\tidFactory: () => string,\n\t\tattributes?: Record<string, unknown>,\n\t) {\n\t\tthis.id = idFactory();\n\t\tthis._attributes = { ...(attributes ?? {}) };\n\t\tthis._recordTrace(OperationTraceEventType.Started, {\n\t\t\toperationName: this._name,\n\t\t\t...this._attributes,\n\t\t});\n\t}\n\n\taddEvent(type: string, attributes?: Record<string, unknown>): void {\n\t\tthis._recordTrace(OperationTraceEventType.Event, {\n\t\t\toperationName: this._name,\n\t\t\teventType: type,\n\t\t\t...this._attributes,\n\t\t\t...(attributes ?? {}),\n\t\t});\n\t}\n\n\tsetAttribute(key: string, value: unknown): void {\n\t\tthis._attributes[key] = value;\n\t}\n\n\trecordError(error: unknown, attributes?: Record<string, unknown>): void {\n\t\tconst errorAttributes = describeError(error);\n\t\tthis._recordTrace(OperationTraceEventType.Error, {\n\t\t\toperationName: this._name,\n\t\t\t...this._attributes,\n\t\t\t...errorAttributes,\n\t\t\t...(attributes ?? {}),\n\t\t});\n\t\tthis._logger?.log({\n\t\t\tlevel: LogLevel.Error,\n\t\t\tmessage: `Operation failed: ${this._name}`,\n\t\t\tscope: this._scope,\n\t\t\tattributes: {\n\t\t\t\toperationId: this.id,\n\t\t\t\toperationName: this._name,\n\t\t\t\t...this._attributes,\n\t\t\t\t...errorAttributes,\n\t\t\t\t...(attributes ?? {}),\n\t\t\t},\n\t\t\terror,\n\t\t\tat: this._clock.now(),\n\t\t});\n\t}\n\n\tend(attributes?: Record<string, unknown>): void {\n\t\tif (this._ended) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._ended = true;\n\t\tthis._recordTrace(OperationTraceEventType.Ended, {\n\t\t\toperationName: this._name,\n\t\t\t...this._attributes,\n\t\t\t...(attributes ?? {}),\n\t\t});\n\t}\n\n\tprivate _recordTrace(\n\t\ttype: string,\n\t\tattributes?: Record<string, unknown>,\n\t): void {\n\t\tthis._traceSink?.record({\n\t\t\ttype,\n\t\t\tat: this._clock.now(),\n\t\t\tscope: this._scope,\n\t\t\tsource: this._source,\n\t\t\toperationId: this.id,\n\t\t\tattributes,\n\t\t});\n\t}\n}\n\nexport function createOperationTracer(\n\toptions: CreateOperationTracerOptions = {},\n): OperationTracerTrait {\n\tconst clock = options.clock ?? defaultClock;\n\tconst idFactory = options.idFactory ?? createDefaultOperationId;\n\n\treturn {\n\t\tstartOperation(name, attributes) {\n\t\t\treturn new DefaultOperationScope(\n\t\t\t\tname,\n\t\t\t\tclock,\n\t\t\t\toptions.traceSink,\n\t\t\t\toptions.logger,\n\t\t\t\toptions.scope,\n\t\t\t\toptions.source,\n\t\t\t\tidFactory,\n\t\t\t\tattributes,\n\t\t\t);\n\t\t},\n\t};\n}\n\nfunction describeError(error: unknown): Record<string, unknown> {\n\tif (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"name\" in error &&\n\t\t\"message\" in error\n\t) {\n\t\tconst genericError = error as Pick<Error, \"name\" | \"message\">;\n\t\treturn {\n\t\t\terrorName: genericError.name,\n\t\t\terrorMessage: genericError.message,\n\t\t};\n\t}\n\n\treturn { errorValue: String(error) };\n}\n","import type { Clock } from \"./types\";\n\n/** Default clock backed by `Date.now()`. */\nexport function createDefaultClock(): Clock {\n\treturn {\n\t\tnow() {\n\t\t\treturn Date.now();\n\t\t},\n\t};\n}\n","import type { CancelableHandle, Scheduler } from \"./types\";\n\n/** Default scheduler backed by platform `setTimeout`. */\nexport function createDefaultScheduler(): Scheduler {\n\treturn {\n\t\tsetTimeout(delayMs: number, fn: () => void): CancelableHandle {\n\t\t\tconst id = globalThis.setTimeout(fn, delayMs);\n\t\t\treturn {\n\t\t\t\tcancel() {\n\t\t\t\t\tglobalThis.clearTimeout(id);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n","import { createOperationTracer } from \"../logging/operation-tracer\";\nimport { createDefaultClock } from \"../scheduling/default-clock\";\nimport { createDefaultScheduler } from \"../scheduling/default-scheduler\";\nimport type { HttpTransport } from \"../transport/types\";\nimport type { ClientEnvironment } from \"./types\";\n\nexport interface CreateClientEnvironmentOptions\n\textends Partial<Omit<ClientEnvironment, \"transport\">> {\n\ttransport: HttpTransport;\n}\n\n/**\n * Create a `ClientEnvironment` with non-host-specific defaults filled in for\n * convenience.\n *\n * Host-specific capabilities such as browser `fetch` should be supplied\n * explicitly or composed via adapter-specific helpers such as\n * `@securitydept/client/web`.\n */\nexport function createClientEnvironment(\n\toverrides: CreateClientEnvironmentOptions,\n): ClientEnvironment {\n\tconst clock = overrides.clock ?? createDefaultClock();\n\tconst traceSink = overrides.traceSink;\n\tconst logger = overrides.logger;\n\n\treturn {\n\t\ttransport: overrides.transport,\n\t\tscheduler: overrides.scheduler ?? createDefaultScheduler(),\n\t\tclock,\n\t\tlogger,\n\t\ttraceSink,\n\t\toperationTracer:\n\t\t\toverrides.operationTracer ??\n\t\t\tcreateOperationTracer({\n\t\t\t\tclock,\n\t\t\t\tlogger,\n\t\t\t\ttraceSink,\n\t\t\t}),\n\t\tpersistentStore: overrides.persistentStore,\n\t\tsessionStore: overrides.sessionStore,\n\t};\n}\n","// Scheduling helpers — foundation-owned convenience over raw Scheduler.\n//\n// These helpers sit above the injectable Scheduler / Clock and provide\n// reusable, cancelable wrappers for common scheduling patterns.\n\nimport type { ReadableSignalTrait } from \"../signals/types\";\nimport type { CancelableHandle, Clock, Scheduler } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Shared types\n// ---------------------------------------------------------------------------\n\n/** Subscription handle returned by input-source adapters. */\nexport interface Subscription {\n\t/** Unsubscribe and release resources. */\n\tunsubscribe(): void;\n}\n\nexport interface FromSignalOptions<T> {\n\t/** Signal to observe. */\n\tsignal: ReadableSignalTrait<T>;\n\t/** Callback invoked when the signal value changes. */\n\tcallback: (value: T) => void;\n\t/**\n\t * Emit the current snapshot immediately after subscription.\n\t * Defaults to `false`.\n\t */\n\temitInitialValue?: boolean;\n}\n\nexport const PromiseSettlementKind = {\n\tFulfilled: \"fulfilled\",\n\tRejected: \"rejected\",\n} as const;\n\nexport type PromiseSettlementKind =\n\t(typeof PromiseSettlementKind)[keyof typeof PromiseSettlementKind];\n\nexport type PromiseSettlement<T> =\n\t| {\n\t\t\tkind: typeof PromiseSettlementKind.Fulfilled;\n\t\t\tvalue: T;\n\t }\n\t| {\n\t\t\tkind: typeof PromiseSettlementKind.Rejected;\n\t\t\treason: unknown;\n\t };\n\nexport interface FromPromiseOptions<T> {\n\t/** Promise-like source to observe. */\n\tpromise: PromiseLike<T>;\n\t/** Callback invoked when the promise settles. */\n\tcallback: (settlement: PromiseSettlement<T>) => void;\n}\n\n// ---------------------------------------------------------------------------\n// timer\n// ---------------------------------------------------------------------------\n\n/** Options for {@link timer}. */\nexport interface TimerOptions {\n\t/** Scheduler to use (platform default if omitted). */\n\tscheduler: Scheduler;\n\t/** Delay in milliseconds. */\n\tdelayMs: number;\n\t/** Callback to invoke after the delay. */\n\tcallback: () => void;\n}\n\n/**\n * Schedule a one-shot callback after a delay.\n *\n * Returns a {@link CancelableHandle} that can cancel the pending timer.\n *\n * @example\n * ```ts\n * const handle = timer({\n * scheduler: runtime.scheduler,\n * delayMs: 5000,\n * callback: () => console.log(\"fired\"),\n * });\n * // Cancel before it fires:\n * handle.cancel();\n * ```\n */\nexport function timer(options: TimerOptions): CancelableHandle {\n\treturn options.scheduler.setTimeout(options.delayMs, options.callback);\n}\n\n// ---------------------------------------------------------------------------\n// interval\n// ---------------------------------------------------------------------------\n\n/** Options for {@link interval}. */\nexport interface IntervalOptions {\n\t/** Scheduler to use. */\n\tscheduler: Scheduler;\n\t/** Interval period in milliseconds. */\n\tperiodMs: number;\n\t/** Callback to invoke on each tick. */\n\tcallback: () => void;\n}\n\n/**\n * Schedule a repeating callback at a fixed interval.\n *\n * Built on top of `Scheduler.setTimeout` so it works with deterministic\n * test schedulers. Returns a {@link CancelableHandle} to stop the interval.\n *\n * @example\n * ```ts\n * const handle = interval({\n * scheduler: runtime.scheduler,\n * periodMs: 30_000,\n * callback: () => refreshTokens(),\n * });\n * // Stop:\n * handle.cancel();\n * ```\n */\nexport function interval(options: IntervalOptions): CancelableHandle {\n\tlet canceled = false;\n\tlet currentHandle: CancelableHandle | null = null;\n\n\tfunction tick(): void {\n\t\tif (canceled) return;\n\t\toptions.callback();\n\t\tscheduleNext();\n\t}\n\n\tfunction scheduleNext(): void {\n\t\tif (canceled) return;\n\t\tcurrentHandle = options.scheduler.setTimeout(options.periodMs, tick);\n\t}\n\n\t// Start the first tick.\n\tscheduleNext();\n\n\treturn {\n\t\tcancel() {\n\t\t\tcanceled = true;\n\t\t\tcurrentHandle?.cancel();\n\t\t\tcurrentHandle = null;\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// scheduleAt\n// ---------------------------------------------------------------------------\n\n/** Options for {@link scheduleAt}. */\nexport interface ScheduleAtOptions {\n\t/** Scheduler to use. */\n\tscheduler: Scheduler;\n\t/** Clock to use for computing the delay. */\n\tclock: Clock;\n\t/** Target epoch milliseconds at which the callback should fire. */\n\tatMs: number;\n\t/** Callback to invoke at (or after) the target time. */\n\tcallback: () => void;\n}\n\n/**\n * Schedule a callback at a specific wall-clock time.\n *\n * Computes the delay from `clock.now()` to `atMs` and delegates to\n * `Scheduler.setTimeout`. If the target time is already in the past,\n * the callback fires on the next scheduler tick (delay 0).\n *\n * @example\n * ```ts\n * const handle = scheduleAt({\n * scheduler: runtime.scheduler,\n * clock: runtime.clock,\n * atMs: tokenExpiresAtMs - 30_000,\n * callback: () => refreshToken(),\n * });\n * ```\n */\nexport function scheduleAt(options: ScheduleAtOptions): CancelableHandle {\n\tconst delay = Math.max(0, options.atMs - options.clock.now());\n\treturn options.scheduler.setTimeout(delay, options.callback);\n}\n\n// ---------------------------------------------------------------------------\n// fromSignal\n// ---------------------------------------------------------------------------\n\n/**\n * Adapt an SDK signal into the shared {@link Subscription} callback model.\n *\n * @example\n * ```ts\n * const sub = fromSignal({\n * signal: authState,\n * callback: (snapshot) => console.log(snapshot),\n * });\n * sub.unsubscribe();\n * ```\n */\nexport function fromSignal<T>(options: FromSignalOptions<T>): Subscription {\n\tif (options.emitInitialValue) {\n\t\toptions.callback(options.signal.get());\n\t}\n\n\tconst unsubscribe = options.signal.subscribe(() => {\n\t\toptions.callback(options.signal.get());\n\t});\n\n\treturn {\n\t\tunsubscribe() {\n\t\t\tunsubscribe();\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// fromPromise\n// ---------------------------------------------------------------------------\n\n/**\n * Adapt a promise settlement into the shared {@link Subscription} callback model.\n *\n * This helper is intentionally thin: it reports one settlement and lets the\n * consumer decide how to model pending/fulfilled/error state.\n *\n * @example\n * ```ts\n * const sub = fromPromise({\n * promise: fetchConfig(),\n * callback: (settlement) => {\n * if (settlement.kind === PromiseSettlementKind.Fulfilled) {\n * console.log(settlement.value);\n * }\n * },\n * });\n * sub.unsubscribe();\n * ```\n */\nexport function fromPromise<T>(options: FromPromiseOptions<T>): Subscription {\n\tlet active = true;\n\n\tvoid Promise.resolve(options.promise).then(\n\t\t(value) => {\n\t\t\tif (!active) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.callback({\n\t\t\t\tkind: PromiseSettlementKind.Fulfilled,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t},\n\t\t(reason) => {\n\t\t\tif (!active) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.callback({\n\t\t\t\tkind: PromiseSettlementKind.Rejected,\n\t\t\t\treason,\n\t\t\t});\n\t\t},\n\t);\n\n\treturn {\n\t\tunsubscribe() {\n\t\t\tactive = false;\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// fromEventPattern\n// ---------------------------------------------------------------------------\n\n/** Options for {@link fromEventPattern}. */\nexport interface FromEventPatternOptions<T> {\n\t/**\n\t * Called to install the event listener. Should return whatever handle\n\t * is needed by `removeHandler` to unsubscribe.\n\t */\n\taddHandler: (handler: (value: T) => void) => void;\n\t/**\n\t * Called to uninstall the event listener.\n\t */\n\tremoveHandler: (handler: (value: T) => void) => void;\n\t/** Callback invoked each time the event fires. */\n\tcallback: (value: T) => void;\n}\n\n/**\n * Adapt an arbitrary add/remove event pattern into a {@link Subscription}.\n *\n * This is a thin bridge between imperative event APIs (e.g. `addEventListener`\n * / `removeEventListener`) and the SDK's subscription model.\n *\n * @example\n * ```ts\n * const sub = fromEventPattern<Event>({\n * addHandler: (h) => document.addEventListener(\"visibilitychange\", h),\n * removeHandler: (h) => document.removeEventListener(\"visibilitychange\", h),\n * callback: () => onVisibilityChange(),\n * });\n * // Cleanup:\n * sub.unsubscribe();\n * ```\n */\nexport function fromEventPattern<T>(\n\toptions: FromEventPatternOptions<T>,\n): Subscription {\n\tconst handler = (value: T): void => {\n\t\toptions.callback(value);\n\t};\n\toptions.addHandler(handler);\n\treturn {\n\t\tunsubscribe() {\n\t\t\toptions.removeHandler(handler);\n\t\t},\n\t};\n}\n","import { fromEventPattern, type Subscription } from \"../scheduling/helpers\";\n\nexport interface AbortSignalSource {\n\taborted: boolean;\n\treason: unknown;\n\taddEventListener(type: string, listener: EventListener): void;\n\tremoveEventListener(type: string, listener: EventListener): void;\n}\n\nexport interface FromAbortSignalOptions {\n\t/** AbortSignal to observe. */\n\tsignal?: AbortSignalSource;\n\t/** Callback invoked when the signal aborts. */\n\tcallback: (reason: unknown) => void;\n\t/**\n\t * Emit immediately when the signal is already aborted at subscribe time.\n\t * Defaults to `false`.\n\t */\n\temitIfAborted?: boolean;\n}\n\nexport interface StorageEventTarget {\n\taddEventListener(type: string, listener: EventListener): void;\n\tremoveEventListener(type: string, listener: EventListener): void;\n}\n\nexport interface FromStorageEventOptions {\n\t/**\n\t * Storage-event target. Defaults to `globalThis`, which is appropriate for\n\t * browser hosts and jsdom-based tests.\n\t */\n\ttarget?: StorageEventTarget;\n\t/** Callback invoked for each browser `storage` event. */\n\tcallback: (event: StorageEvent) => void;\n}\n\n/**\n * Adapt a browser AbortSignal into the shared Subscription model.\n */\nexport function fromAbortSignal(options: FromAbortSignalOptions): Subscription {\n\tconst signal = options.signal;\n\tif (!signal) {\n\t\treturn {\n\t\t\tunsubscribe() {},\n\t\t};\n\t}\n\n\tif (options.emitIfAborted && signal.aborted) {\n\t\toptions.callback(signal.reason);\n\t}\n\n\treturn fromEventPattern<Event>({\n\t\taddHandler: (handler) => {\n\t\t\tsignal.addEventListener(\"abort\", handler);\n\t\t},\n\t\tremoveHandler: (handler) => {\n\t\t\tsignal.removeEventListener(\"abort\", handler);\n\t\t},\n\t\tcallback: () => {\n\t\t\toptions.callback(signal.reason);\n\t\t},\n\t});\n}\n\n/**\n * Adapt browser `storage` events into the shared Subscription model.\n */\nexport function fromStorageEvent(\n\toptions: FromStorageEventOptions,\n): Subscription {\n\tconst target = options.target ?? (globalThis as StorageEventTarget);\n\n\treturn fromEventPattern<Event>({\n\t\taddHandler: (handler) => {\n\t\t\ttarget.addEventListener(\"storage\", handler);\n\t\t},\n\t\tremoveHandler: (handler) => {\n\t\t\ttarget.removeEventListener(\"storage\", handler);\n\t\t},\n\t\tcallback: (event) => {\n\t\t\toptions.callback(event as StorageEvent);\n\t\t},\n\t});\n}\n","import type {\n\tCancellationTokenTrait,\n\tDisposableTrait,\n} from \"../cancellation/types\";\nimport { ClientError } from \"../errors/client-error\";\nimport { ClientErrorKind, ClientErrorSource } from \"../errors/types\";\nimport { fromAbortSignal } from \"./input-sources\";\n\nexport interface AbortSignalBridge {\n\tsignal?: AbortSignal;\n\tdispose(): void;\n}\n\n/**\n * Bridge a web `AbortSignal` back into the foundation cancellation contract.\n *\n * This is the canonical consumer-side path for browser hosts that receive an\n * `AbortSignal` from framework/runtime APIs (for example React Query queryFns)\n * but need to call SDK surfaces that accept `CancellationTokenTrait`.\n */\nexport function createCancellationTokenFromAbortSignal(\n\tsignal?: AbortSignal,\n): CancellationTokenTrait | undefined {\n\tif (!signal) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tget isCancellationRequested() {\n\t\t\treturn signal.aborted;\n\t\t},\n\t\tget reason() {\n\t\t\treturn signal.reason;\n\t\t},\n\t\tonCancellationRequested(listener: (reason: unknown) => void) {\n\t\t\tconst subscription = fromAbortSignal({\n\t\t\t\tsignal,\n\t\t\t\tcallback: listener,\n\t\t\t\temitIfAborted: true,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tdispose() {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tthrowIfCancellationRequested() {\n\t\t\tif (signal.aborted) {\n\t\t\t\tthrow new ClientError({\n\t\t\t\t\tkind: ClientErrorKind.Cancelled,\n\t\t\t\t\tmessage: \"Request was cancelled via AbortSignal\",\n\t\t\t\t\tcode: \"client.cancelled\",\n\t\t\t\t\tsource: ClientErrorSource.Transport,\n\t\t\t\t\tcause: signal.reason,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Bridge foundation cancellation to web `AbortSignal` without exposing\n * `AbortSignal` in core contracts.\n */\nexport function createAbortSignalBridge(\n\ttoken?: CancellationTokenTrait,\n): AbortSignalBridge {\n\tif (!token) {\n\t\treturn {\n\t\t\tsignal: undefined,\n\t\t\tdispose() {},\n\t\t};\n\t}\n\n\tconst controller = new AbortController();\n\tlet subscription: DisposableTrait | null = token.onCancellationRequested(\n\t\t(reason) => {\n\t\t\tcontroller.abort(reason);\n\t\t},\n\t);\n\n\tif (token.isCancellationRequested) {\n\t\tcontroller.abort(token.reason);\n\t}\n\n\treturn {\n\t\tsignal: controller.signal,\n\t\tdispose() {\n\t\t\tsubscription?.dispose();\n\t\t\tsubscription = null;\n\t\t},\n\t};\n}\n\nexport function normalizeAbortError(\n\ttoken: CancellationTokenTrait | undefined,\n\terror: unknown,\n): unknown {\n\tif (!isAbortError(error) && !token?.isCancellationRequested) {\n\t\treturn error;\n\t}\n\n\tconst reason = token?.reason;\n\tif (reason instanceof ClientError) {\n\t\treturn reason;\n\t}\n\n\tif (reason instanceof Error) {\n\t\treturn new ClientError({\n\t\t\tkind: ClientErrorKind.Cancelled,\n\t\t\tmessage: reason.message,\n\t\t\tcode: \"client.cancelled\",\n\t\t\tsource: ClientErrorSource.Transport,\n\t\t\tcause: reason,\n\t\t});\n\t}\n\n\treturn new ClientError({\n\t\tkind: ClientErrorKind.Cancelled,\n\t\tmessage: \"HTTP request was cancelled\",\n\t\tcode: \"client.cancelled\",\n\t\tsource: ClientErrorSource.Transport,\n\t\tcause: reason ?? error,\n\t});\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"name\" in error &&\n\t\terror.name === \"AbortError\"\n\t);\n}\n","import {\n\tcreateAbortSignalBridge,\n\tnormalizeAbortError,\n} from \"../web/cancellation\";\nimport type { HttpRequest, HttpResponse, HttpTransport } from \"./types\";\n\nexport const FetchTransportRedirectKind = {\n\tFollow: \"follow\",\n\tManual: \"manual\",\n} as const;\n\nexport type FetchTransportRedirectKind =\n\t(typeof FetchTransportRedirectKind)[keyof typeof FetchTransportRedirectKind];\n\nexport interface FetchTransportOptions {\n\t/**\n\t * How to handle HTTP redirects.\n\t * - `\"follow\"`: automatically follow redirects (default fetch behavior)\n\t * - `\"manual\"`: capture redirect responses as-is (needed for fragment-based protocols)\n\t */\n\tredirect?: FetchTransportRedirectKind;\n}\n\n/**\n * Default `HttpTransport` backed by the global `fetch` API.\n *\n * The caller is responsible for ensuring `fetch` is available in the runtime.\n * No polyfill is injected — see the polyfill strategy in the design guide.\n */\nexport function createFetchTransport(\n\toptions: FetchTransportOptions = {},\n): HttpTransport {\n\tconst redirect = options.redirect ?? FetchTransportRedirectKind.Manual;\n\n\treturn {\n\t\tasync execute(request: HttpRequest): Promise<HttpResponse> {\n\t\t\tconst abortBridge = createAbortSignalBridge(request.cancellationToken);\n\t\t\tconst init: RequestInit = {\n\t\t\t\tmethod: request.method,\n\t\t\t\theaders: request.headers,\n\t\t\t\tredirect,\n\t\t\t\tsignal: abortBridge.signal,\n\t\t\t};\n\n\t\t\tif (\n\t\t\t\trequest.body !== undefined &&\n\t\t\t\trequest.method !== \"GET\" &&\n\t\t\t\trequest.method !== \"HEAD\"\n\t\t\t) {\n\t\t\t\tinit.body =\n\t\t\t\t\ttypeof request.body === \"string\"\n\t\t\t\t\t\t? request.body\n\t\t\t\t\t\t: JSON.stringify(request.body);\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst res = await fetch(request.url, init);\n\n\t\t\t\tconst responseHeaders: Record<string, string> = {};\n\t\t\t\tres.headers.forEach((value, key) => {\n\t\t\t\t\tresponseHeaders[key] = value;\n\t\t\t\t});\n\n\t\t\t\tlet body: unknown;\n\t\t\t\tconst contentType = res.headers.get(\"content-type\");\n\t\t\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\t\t\tbody = await res.json();\n\t\t\t\t} else if (\n\t\t\t\t\tres.status !== 302 &&\n\t\t\t\t\tres.status !== 303 &&\n\t\t\t\t\tres.status !== 301\n\t\t\t\t) {\n\t\t\t\t\tbody = await res.text();\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\theaders: responseHeaders,\n\t\t\t\t\tbody,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tthrow normalizeAbortError(request.cancellationToken, error);\n\t\t\t} finally {\n\t\t\t\tabortBridge.dispose();\n\t\t\t}\n\t\t},\n\t};\n}\n","import { createClientEnvironment } from \"../runtime/create-runtime\";\nimport type { ClientEnvironment } from \"../runtime/types\";\nimport {\n\tcreateFetchTransport,\n\ttype FetchTransportOptions,\n} from \"../transport/fetch-transport\";\n\nexport interface CreateWebClientEnvironmentDependenciesOptions\n\textends Partial<Omit<ClientEnvironment, \"transport\">> {\n\ttransport?: ClientEnvironment[\"transport\"];\n\tfetchTransport?: FetchTransportOptions;\n}\n\n/**\n * Create a `ClientEnvironment` for browser/Web-capable environments.\n */\nexport function createWebClientEnvironmentDependencies(\n\toverrides: CreateWebClientEnvironmentDependenciesOptions = {},\n): ClientEnvironment {\n\tconst { fetchTransport, transport, ...environment } = overrides;\n\treturn createClientEnvironment({\n\t\t...environment,\n\t\ttransport: transport ?? createFetchTransport(fetchTransport),\n\t});\n}\n","import {\n\tcreateLocalStorageStore,\n\tcreateSessionStorageStore,\n} from \"../persistence/web\";\nimport type { ClientEnvironment as FoundationClientEnvironment } from \"../runtime/types\";\nimport type { FetchTransportOptions } from \"../transport/fetch-transport\";\nimport { createWebClientEnvironmentDependencies } from \"./runtime\";\n\nexport type { ClientEnvironment } from \"../runtime/types\";\n\nexport const ClientEnvironmentPreset = {\n\tBrowserPage: \"browser_page\",\n\tBrowserWorker: \"browser_worker\",\n\tServiceWorker: \"service_worker\",\n\tBrowserExtensionBackground: \"browser_extension_background\",\n} as const;\nexport type ClientEnvironmentPreset =\n\t(typeof ClientEnvironmentPreset)[keyof typeof ClientEnvironmentPreset];\n\nexport interface WebClientEnvironment extends FoundationClientEnvironment {\n\tpreset?: ClientEnvironmentPreset;\n}\n\nexport interface PageLocationLike {\n\thref: string;\n\thash: string;\n\tpathname?: string;\n\tsearch?: string;\n}\n\nexport interface PageHistoryLike {\n\treplaceState(data: unknown, unused: string, url?: string | URL | null): void;\n}\n\nexport interface PageLocationCapability {\n\tlocation: PageLocationLike;\n}\n\nexport interface PageLocationHistoryCapability extends PageLocationCapability {\n\thistory: PageHistoryLike;\n}\n\nexport interface PageClientEnvironment\n\textends WebClientEnvironment,\n\t\tPageLocationHistoryCapability {}\n\nexport interface CreateWebClientEnvironmentOptions\n\textends Partial<Omit<FoundationClientEnvironment, \"transport\">> {\n\ttransport?: FoundationClientEnvironment[\"transport\"];\n\tfetchTransport?: FetchTransportOptions;\n\tpreset?: ClientEnvironmentPreset;\n}\n\nexport interface CreateBrowserPageClientEnvironmentOptions\n\textends CreateWebClientEnvironmentOptions {\n\tpageCapability?: PageLocationHistoryCapability;\n}\n\nexport interface RequirePageClientEnvironmentOptions {\n\tenvironment?: WebClientEnvironment | PageClientEnvironment;\n\tpageCapability?: PageLocationHistoryCapability;\n}\n\nconst PAGE_LOCATION_ERROR_MESSAGE =\n\t\"browser redirect helpers require a page-like window.location.\\n\" +\n\t\"For extension background or service worker hosts, keep redirects in a real page context or pass explicit location capability.\";\n\nconst PAGE_LOCATION_HISTORY_ERROR_MESSAGE =\n\t\"backend-oidc page callback bootstrap requires a page-like window.location and window.history.\\n\" +\n\t\"For extension background or service worker hosts, use restore-only flow or pass explicit location/history/store capabilities.\";\n\nconst EXPLICIT_PAGE_ENVIRONMENT_ERROR_MESSAGE =\n\t\"page helpers require an explicit page environment.\\n\" +\n\t\"Create one in your composition root with createBrowserPageClientEnvironment(...).\\n\" +\n\t\"For worker, service worker, or extension background hosts, keep page-only redirects and callbacks in a real page context.\";\n\nconst EXPLICIT_PAGE_LOCATION_HISTORY_CAPABILITY_ERROR_MESSAGE =\n\t\"page helpers require an explicit page environment with location and history.\\n\" +\n\t\"Create one in your composition root with createBrowserPageClientEnvironment(...), or pass an explicit pageCapability override.\";\n\nconst BROWSER_PERSISTENT_PREFIX = \"securitydept.web.client:\";\nconst BROWSER_SESSION_PREFIX = \"securitydept.web.client:\";\n\nexport function createWebClientEnvironment(\n\toptions: CreateWebClientEnvironmentOptions = {},\n): WebClientEnvironment {\n\tconst { preset, ...environmentOptions } = options;\n\tconst resolvedEnvironment =\n\t\tcreateWebClientEnvironmentDependencies(environmentOptions);\n\treturn {\n\t\t...resolvedEnvironment,\n\t\tpreset,\n\t};\n}\n\nexport function deriveClientEnvironment(\n\tenvironment: FoundationClientEnvironment,\n): FoundationClientEnvironment {\n\treturn {\n\t\ttransport: environment.transport,\n\t\tscheduler: environment.scheduler,\n\t\tclock: environment.clock,\n\t\tlogger: environment.logger,\n\t\ttraceSink: environment.traceSink,\n\t\toperationTracer: environment.operationTracer,\n\t\tpersistentStore: environment.persistentStore,\n\t\tsessionStore: environment.sessionStore,\n\t};\n}\n\nexport function createBrowserPageClientEnvironment(\n\toptions: CreateBrowserPageClientEnvironmentOptions = {},\n): PageClientEnvironment {\n\tconst pageCapability = options.pageCapability\n\t\t? assertPageLocationHistoryCapability(options.pageCapability)\n\t\t: requireDefaultPageLocationHistoryCapability();\n\n\treturn {\n\t\t...createWebClientEnvironment({\n\t\t\t...withDefaultBrowserStores(options),\n\t\t\tpreset: ClientEnvironmentPreset.BrowserPage,\n\t\t}),\n\t\t...pageCapability,\n\t};\n}\n\nexport function readDefaultPageLocationCapability(): PageLocationCapability | null {\n\tconst windowLike = (globalThis as unknown as { window?: unknown }).window;\n\tif (!isObject(windowLike)) {\n\t\treturn null;\n\t}\n\n\tconst location = (windowLike as { location?: unknown }).location;\n\treturn readPageLocationCapability({ location });\n}\n\nexport function requireDefaultPageLocationCapability(): PageLocationCapability {\n\tconst pageCapability = readDefaultPageLocationCapability();\n\tif (!pageCapability) {\n\t\tthrow new Error(PAGE_LOCATION_ERROR_MESSAGE);\n\t}\n\n\treturn pageCapability;\n}\n\nexport function createBrowserWorkerClientEnvironment(\n\toptions: CreateWebClientEnvironmentOptions = {},\n): WebClientEnvironment {\n\treturn createWebClientEnvironment({\n\t\t...options,\n\t\tpreset: ClientEnvironmentPreset.BrowserWorker,\n\t});\n}\n\nexport function createServiceWorkerClientEnvironment(\n\toptions: CreateWebClientEnvironmentOptions = {},\n): WebClientEnvironment {\n\treturn createWebClientEnvironment({\n\t\t...options,\n\t\tpreset: ClientEnvironmentPreset.ServiceWorker,\n\t});\n}\n\nexport function createBrowserExtensionBackgroundClientEnvironment(\n\toptions: CreateWebClientEnvironmentOptions = {},\n): WebClientEnvironment {\n\treturn createWebClientEnvironment({\n\t\t...options,\n\t\tpreset: ClientEnvironmentPreset.BrowserExtensionBackground,\n\t});\n}\n\nexport function assertResolveEnvironment<T>(\n\tenvironment: T | null | undefined,\n\tonResolvingEnvironmentFail: () => never,\n): Exclude<T, null | undefined> {\n\tif (environment === null || environment === undefined) {\n\t\treturn onResolvingEnvironmentFail();\n\t}\n\n\treturn environment as Exclude<T, null | undefined>;\n}\n\nexport function assertResolveFromEnvironment<TEnvironment, TValue>(\n\tenvironment: TEnvironment | null | undefined,\n\tselect: (environment: TEnvironment) => TValue | null | undefined,\n\tonResolvingCapabilityFail: () => never,\n): Exclude<TValue, null | undefined> {\n\tconst resolvedEnvironment = assertResolveEnvironment(\n\t\tenvironment,\n\t\tonResolvingCapabilityFail,\n\t);\n\tconst resolvedValue = select(resolvedEnvironment);\n\tif (resolvedValue === null || resolvedValue === undefined) {\n\t\treturn onResolvingCapabilityFail();\n\t}\n\n\treturn resolvedValue as Exclude<TValue, null | undefined>;\n}\n\nexport function requirePageClientEnvironment(\n\tenvironmentOrOptions?:\n\t\t| PageClientEnvironment\n\t\t| RequirePageClientEnvironmentOptions,\n): PageClientEnvironment {\n\tconst options =\n\t\tnormalizeRequirePageClientEnvironmentOptions(environmentOrOptions);\n\tconst environment = assertResolveEnvironment(\n\t\toptions.environment,\n\t\tfailMissingPageEnvironment,\n\t);\n\tconst pageCapability = resolvePageLocationHistoryCapability(\n\t\toptions,\n\t\tenvironment,\n\t);\n\n\treturn {\n\t\t...environment,\n\t\t...pageCapability,\n\t};\n}\n\nexport function readDefaultPageLocationHistoryCapability(): PageLocationHistoryCapability | null {\n\tconst windowLike = (globalThis as unknown as { window?: unknown }).window;\n\tif (!isObject(windowLike)) {\n\t\treturn null;\n\t}\n\n\tconst location = (windowLike as { location?: unknown }).location;\n\tconst history = (windowLike as { history?: unknown }).history;\n\treturn readPageLocationHistoryCapability({ location, history });\n}\n\nexport function requireDefaultPageLocationHistoryCapability(): PageLocationHistoryCapability {\n\tconst pageCapability = readDefaultPageLocationHistoryCapability();\n\tif (!pageCapability) {\n\t\tthrow new Error(PAGE_LOCATION_HISTORY_ERROR_MESSAGE);\n\t}\n\n\treturn pageCapability;\n}\n\nexport function readPageLocationCapability(input: {\n\tlocation?: unknown;\n}): PageLocationCapability | null {\n\tconst location = input.location;\n\tif (!isPageLocationLike(location)) {\n\t\treturn null;\n\t}\n\n\treturn { location };\n}\n\nexport function readPageLocationHistoryCapability(input: {\n\tlocation?: unknown;\n\thistory?: unknown;\n}): PageLocationHistoryCapability | null {\n\tconst pageCapability = readPageLocationCapability(input);\n\tconst history = input.history;\n\tif (!pageCapability || !isPageHistoryLike(history)) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...pageCapability,\n\t\thistory,\n\t};\n}\n\nexport function assertPageLocationCapability(\n\tpageCapability: unknown,\n\tfieldName = \"environment\",\n): PageLocationCapability {\n\tif (!isObject(pageCapability)) {\n\t\tthrow new Error(\n\t\t\t`${fieldName} must include location.href and location.hash.\\n${PAGE_LOCATION_ERROR_MESSAGE}`,\n\t\t);\n\t}\n\n\tconst normalized = readPageLocationCapability(\n\t\tpageCapability as { location?: unknown },\n\t);\n\tif (!normalized) {\n\t\tthrow new Error(\n\t\t\t`${fieldName} must include location.href and location.hash.\\n${PAGE_LOCATION_ERROR_MESSAGE}`,\n\t\t);\n\t}\n\n\treturn normalized;\n}\n\nexport function assertPageLocationHistoryCapability(\n\tpageCapability: unknown,\n\tfieldName = \"pageCapability\",\n): PageLocationHistoryCapability {\n\tif (!isObject(pageCapability)) {\n\t\tthrow new Error(\n\t\t\t`${fieldName} must include location.href, location.hash, and history.replaceState.\\n${PAGE_LOCATION_HISTORY_ERROR_MESSAGE}`,\n\t\t);\n\t}\n\n\tconst normalized = readPageLocationHistoryCapability(\n\t\tpageCapability as { location?: unknown; history?: unknown },\n\t);\n\tif (!normalized) {\n\t\tthrow new Error(\n\t\t\t`${fieldName} must include location.href, location.hash, and history.replaceState.\\n${PAGE_LOCATION_HISTORY_ERROR_MESSAGE}`,\n\t\t);\n\t}\n\n\treturn normalized;\n}\n\nfunction normalizeRequirePageClientEnvironmentOptions(\n\tenvironmentOrOptions?:\n\t\t| PageClientEnvironment\n\t\t| RequirePageClientEnvironmentOptions,\n): RequirePageClientEnvironmentOptions {\n\tif (!environmentOrOptions) {\n\t\treturn {};\n\t}\n\n\tif (\"transport\" in environmentOrOptions) {\n\t\treturn { environment: environmentOrOptions };\n\t}\n\n\treturn environmentOrOptions;\n}\n\nfunction resolvePageLocationHistoryCapability(\n\toptions: RequirePageClientEnvironmentOptions,\n\tenvironment: WebClientEnvironment | PageClientEnvironment,\n): PageLocationHistoryCapability {\n\tif (options.pageCapability !== undefined) {\n\t\treturn assertPageLocationHistoryCapability(\n\t\t\toptions.pageCapability,\n\t\t\t\"pageCapability\",\n\t\t);\n\t}\n\n\treturn assertResolveFromEnvironment(\n\t\tenvironment,\n\t\t(candidateEnvironment) =>\n\t\t\treadPageLocationHistoryCapability(\n\t\t\t\tcandidateEnvironment as { location?: unknown; history?: unknown },\n\t\t\t),\n\t\tfailMissingPageLocationHistoryCapability,\n\t);\n}\n\nfunction failMissingPageEnvironment(): never {\n\tthrow new Error(EXPLICIT_PAGE_ENVIRONMENT_ERROR_MESSAGE);\n}\n\nfunction failMissingPageLocationHistoryCapability(): never {\n\tthrow new Error(EXPLICIT_PAGE_LOCATION_HISTORY_CAPABILITY_ERROR_MESSAGE);\n}\n\nfunction withDefaultBrowserStores<\n\tTOptions extends CreateWebClientEnvironmentOptions,\n>(options: TOptions): TOptions {\n\treturn {\n\t\t...options,\n\t\tpersistentStore:\n\t\t\toptions.persistentStore ??\n\t\t\tcreateLocalStorageStore(BROWSER_PERSISTENT_PREFIX),\n\t\tsessionStore:\n\t\t\toptions.sessionStore ?? createSessionStorageStore(BROWSER_SESSION_PREFIX),\n\t};\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isPageLocationLike(value: unknown): value is PageLocationLike {\n\treturn (\n\t\tisObject(value) &&\n\t\ttypeof value.href === \"string\" &&\n\t\ttypeof value.hash === \"string\"\n\t);\n}\n\nfunction isPageHistoryLike(value: unknown): value is PageHistoryLike {\n\treturn isObject(value) && typeof value.replaceState === \"function\";\n}\n"],"mappings":";;;AAIA,MAAa,eAAe;CAC3B,MAAM;CACN,OAAO;CACP,aAAa;CACb,gBAAgB;CAChB,gBAAgB;CAChB;AAWD,MAAa,wBAAwB;CACpC,SAAS;CACT,SAAS;CACT,QAAQ;CACR;;AA+BD,MAAa,kBAAkB;CAC9B,eAAe;CACf,WAAW;CACX,QAAQ;CACR,UAAU;CACV,cAAc;CACd,YAAY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AAI,MACT,GAAG,UAAU,yEAAyE,sCACtF;CAGF,OAAO;;AAGR,SAAS,6CACR,sBAGsC;CACtC,IAAI,CAAC,sBACJ,OAAO,EAAE;CAGV,IAAI,eAAe,sBAClB,OAAO,EAAE,aAAa,sBAAsB;CAG7C,OAAO;;AAGR,SAAS,qCACR,SACA,aACgC;CAChC,IAAI,QAAQ,mBAAmB,KAAA,GAC9B,OAAO,oCACN,QAAQ,gBACR,iBACA;CAGF,OAAO,6BACN,cACC,yBACA,kCACC,qBACA,EACF,yCACA;;AAGF,SAAS,6BAAoC;CAC5C,MAAM,IAAI,MAAM,wCAAwC;;AAGzD,SAAS,2CAAkD;CAC1D,MAAM,IAAI,MAAM,wDAAwD;;AAGzE,SAAS,yBAEP,SAA6B;CAC9B,OAAO;EACN,GAAG;EACH,iBACC,QAAQ,mBACR,wBAAwB,0BAA0B;EACnD,cACC,QAAQ,gBAAgB,0BAA0B,uBAAuB;EAC1E;;AAGF,SAAS,SAAS,OAAkD;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU;;AAG/C,SAAS,mBAAmB,OAA2C;CACtE,OACC,SAAS,MAAM,IACf,OAAO,MAAM,SAAS,YACtB,OAAO,MAAM,SAAS;;AAIxB,SAAS,kBAAkB,OAA0C;CACpE,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,iBAAiB"}
@@ -1,401 +0,0 @@
1
- import { n as ReadableSignalTrait } from "./types-BJqUdH2e.mjs";
2
- import { a as RecordStore } from "./types-BwcnUGNl.mjs";
3
-
4
- //#region src/cancellation/types.d.ts
5
- /** Disposable resource handle. */
6
- interface DisposableTrait {
7
- dispose(): void;
8
- }
9
- /** Cancelable operation handle. */
10
- interface CancelableHandle$1 {
11
- cancel(): void;
12
- }
13
- /** Cooperative cancellation token — consumers check / subscribe to cancellation. */
14
- interface CancellationTokenTrait {
15
- readonly isCancellationRequested: boolean;
16
- readonly reason?: unknown;
17
- onCancellationRequested(listener: (reason: unknown) => void): DisposableTrait;
18
- throwIfCancellationRequested(): void;
19
- }
20
- /** Cancellation source — producer-side control. */
21
- interface CancellationTokenSourceTrait extends DisposableTrait {
22
- readonly token: CancellationTokenTrait;
23
- cancel(reason?: unknown): void;
24
- }
25
- //#endregion
26
- //#region src/logging/types.d.ts
27
- declare const LogLevel: {
28
- readonly Debug: "debug";
29
- readonly Info: "info";
30
- readonly Warn: "warn";
31
- readonly Error: "error";
32
- };
33
- type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
34
- interface LogEntry {
35
- level: LogLevel;
36
- message: string;
37
- scope?: string;
38
- code?: string;
39
- attributes?: Record<string, unknown>;
40
- error?: unknown;
41
- at?: number;
42
- }
43
- interface LoggerTrait {
44
- log(entry: LogEntry): void;
45
- }
46
- declare const OperationTraceEventType: {
47
- readonly Started: "operation.started";
48
- readonly Event: "operation.event";
49
- readonly Error: "operation.error";
50
- readonly Ended: "operation.ended";
51
- };
52
- type OperationTraceEventType = (typeof OperationTraceEventType)[keyof typeof OperationTraceEventType];
53
- interface TraceEvent {
54
- type: string;
55
- at: number;
56
- scope?: string;
57
- operationId?: string;
58
- source?: string;
59
- attributes?: Record<string, unknown>;
60
- }
61
- interface TraceEventSinkTrait {
62
- record(event: TraceEvent): void;
63
- }
64
- interface OperationScope {
65
- id: string;
66
- addEvent(type: string, attributes?: Record<string, unknown>): void;
67
- setAttribute(key: string, value: unknown): void;
68
- recordError(error: unknown, attributes?: Record<string, unknown>): void;
69
- end(attributes?: Record<string, unknown>): void;
70
- }
71
- interface OperationTracerTrait {
72
- startOperation(name: string, attributes?: Record<string, unknown>): OperationScope;
73
- }
74
- //#endregion
75
- //#region src/scheduling/types.d.ts
76
- /** Wall clock abstraction — injectable for testing. */
77
- interface Clock {
78
- /** Return current epoch milliseconds. */
79
- now(): number;
80
- }
81
- /** Cancelable scheduled task handle. */
82
- interface CancelableHandle {
83
- cancel(): void;
84
- }
85
- /** Scheduler abstraction — decoupled from platform timers. */
86
- interface Scheduler {
87
- setTimeout(delayMs: number, fn: () => void): CancelableHandle;
88
- }
89
- //#endregion
90
- //#region src/transport/types.d.ts
91
- /** Neutral HTTP request representation. */
92
- interface HttpRequest {
93
- url: string;
94
- method: string;
95
- headers: Record<string, string>;
96
- body?: unknown;
97
- cancellationToken?: CancellationTokenTrait;
98
- }
99
- /** Neutral HTTP response representation. */
100
- interface HttpResponse {
101
- status: number;
102
- headers: Record<string, string>;
103
- body?: unknown;
104
- }
105
- /** Transport protocol — decoupled from any specific HTTP client. */
106
- interface HttpTransport {
107
- execute(request: HttpRequest): Promise<HttpResponse>;
108
- }
109
- //#endregion
110
- //#region src/runtime/types.d.ts
111
- /**
112
- * Client dependency environment injected into auth context clients
113
- * via explicit wiring at the composition root.
114
- *
115
- * All capabilities are optional except `transport`.
116
- * Missing capabilities use no-op defaults where applicable.
117
- * `createClientEnvironment()` is a convenience helper for common setups;
118
- * callers can also wire this interface directly.
119
- */
120
- interface ClientEnvironment {
121
- transport: HttpTransport;
122
- scheduler: Scheduler;
123
- clock: Clock;
124
- logger?: LoggerTrait;
125
- traceSink?: TraceEventSinkTrait;
126
- operationTracer?: OperationTracerTrait;
127
- /** Optional persistent storage backing. */
128
- persistentStore?: RecordStore;
129
- /** Optional session-scoped storage backing. */
130
- sessionStore?: RecordStore;
131
- }
132
- //#endregion
133
- //#region src/scheduling/helpers.d.ts
134
- /** Subscription handle returned by input-source adapters. */
135
- interface Subscription {
136
- /** Unsubscribe and release resources. */
137
- unsubscribe(): void;
138
- }
139
- interface FromSignalOptions<T> {
140
- /** Signal to observe. */
141
- signal: ReadableSignalTrait<T>;
142
- /** Callback invoked when the signal value changes. */
143
- callback: (value: T) => void;
144
- /**
145
- * Emit the current snapshot immediately after subscription.
146
- * Defaults to `false`.
147
- */
148
- emitInitialValue?: boolean;
149
- }
150
- declare const PromiseSettlementKind: {
151
- readonly Fulfilled: "fulfilled";
152
- readonly Rejected: "rejected";
153
- };
154
- type PromiseSettlementKind = (typeof PromiseSettlementKind)[keyof typeof PromiseSettlementKind];
155
- type PromiseSettlement<T> = {
156
- kind: typeof PromiseSettlementKind.Fulfilled;
157
- value: T;
158
- } | {
159
- kind: typeof PromiseSettlementKind.Rejected;
160
- reason: unknown;
161
- };
162
- interface FromPromiseOptions<T> {
163
- /** Promise-like source to observe. */
164
- promise: PromiseLike<T>;
165
- /** Callback invoked when the promise settles. */
166
- callback: (settlement: PromiseSettlement<T>) => void;
167
- }
168
- /** Options for {@link timer}. */
169
- interface TimerOptions {
170
- /** Scheduler to use (platform default if omitted). */
171
- scheduler: Scheduler;
172
- /** Delay in milliseconds. */
173
- delayMs: number;
174
- /** Callback to invoke after the delay. */
175
- callback: () => void;
176
- }
177
- /**
178
- * Schedule a one-shot callback after a delay.
179
- *
180
- * Returns a {@link CancelableHandle} that can cancel the pending timer.
181
- *
182
- * @example
183
- * ```ts
184
- * const handle = timer({
185
- * scheduler: runtime.scheduler,
186
- * delayMs: 5000,
187
- * callback: () => console.log("fired"),
188
- * });
189
- * // Cancel before it fires:
190
- * handle.cancel();
191
- * ```
192
- */
193
- declare function timer(options: TimerOptions): CancelableHandle;
194
- /** Options for {@link interval}. */
195
- interface IntervalOptions {
196
- /** Scheduler to use. */
197
- scheduler: Scheduler;
198
- /** Interval period in milliseconds. */
199
- periodMs: number;
200
- /** Callback to invoke on each tick. */
201
- callback: () => void;
202
- }
203
- /**
204
- * Schedule a repeating callback at a fixed interval.
205
- *
206
- * Built on top of `Scheduler.setTimeout` so it works with deterministic
207
- * test schedulers. Returns a {@link CancelableHandle} to stop the interval.
208
- *
209
- * @example
210
- * ```ts
211
- * const handle = interval({
212
- * scheduler: runtime.scheduler,
213
- * periodMs: 30_000,
214
- * callback: () => refreshTokens(),
215
- * });
216
- * // Stop:
217
- * handle.cancel();
218
- * ```
219
- */
220
- declare function interval(options: IntervalOptions): CancelableHandle;
221
- /** Options for {@link scheduleAt}. */
222
- interface ScheduleAtOptions {
223
- /** Scheduler to use. */
224
- scheduler: Scheduler;
225
- /** Clock to use for computing the delay. */
226
- clock: Clock;
227
- /** Target epoch milliseconds at which the callback should fire. */
228
- atMs: number;
229
- /** Callback to invoke at (or after) the target time. */
230
- callback: () => void;
231
- }
232
- /**
233
- * Schedule a callback at a specific wall-clock time.
234
- *
235
- * Computes the delay from `clock.now()` to `atMs` and delegates to
236
- * `Scheduler.setTimeout`. If the target time is already in the past,
237
- * the callback fires on the next scheduler tick (delay 0).
238
- *
239
- * @example
240
- * ```ts
241
- * const handle = scheduleAt({
242
- * scheduler: runtime.scheduler,
243
- * clock: runtime.clock,
244
- * atMs: tokenExpiresAtMs - 30_000,
245
- * callback: () => refreshToken(),
246
- * });
247
- * ```
248
- */
249
- declare function scheduleAt(options: ScheduleAtOptions): CancelableHandle;
250
- /**
251
- * Adapt an SDK signal into the shared {@link Subscription} callback model.
252
- *
253
- * @example
254
- * ```ts
255
- * const sub = fromSignal({
256
- * signal: authState,
257
- * callback: (snapshot) => console.log(snapshot),
258
- * });
259
- * sub.unsubscribe();
260
- * ```
261
- */
262
- declare function fromSignal<T>(options: FromSignalOptions<T>): Subscription;
263
- /**
264
- * Adapt a promise settlement into the shared {@link Subscription} callback model.
265
- *
266
- * This helper is intentionally thin: it reports one settlement and lets the
267
- * consumer decide how to model pending/fulfilled/error state.
268
- *
269
- * @example
270
- * ```ts
271
- * const sub = fromPromise({
272
- * promise: fetchConfig(),
273
- * callback: (settlement) => {
274
- * if (settlement.kind === PromiseSettlementKind.Fulfilled) {
275
- * console.log(settlement.value);
276
- * }
277
- * },
278
- * });
279
- * sub.unsubscribe();
280
- * ```
281
- */
282
- declare function fromPromise<T>(options: FromPromiseOptions<T>): Subscription;
283
- /** Options for {@link fromEventPattern}. */
284
- interface FromEventPatternOptions<T> {
285
- /**
286
- * Called to install the event listener. Should return whatever handle
287
- * is needed by `removeHandler` to unsubscribe.
288
- */
289
- addHandler: (handler: (value: T) => void) => void;
290
- /**
291
- * Called to uninstall the event listener.
292
- */
293
- removeHandler: (handler: (value: T) => void) => void;
294
- /** Callback invoked each time the event fires. */
295
- callback: (value: T) => void;
296
- }
297
- /**
298
- * Adapt an arbitrary add/remove event pattern into a {@link Subscription}.
299
- *
300
- * This is a thin bridge between imperative event APIs (e.g. `addEventListener`
301
- * / `removeEventListener`) and the SDK's subscription model.
302
- *
303
- * @example
304
- * ```ts
305
- * const sub = fromEventPattern<Event>({
306
- * addHandler: (h) => document.addEventListener("visibilitychange", h),
307
- * removeHandler: (h) => document.removeEventListener("visibilitychange", h),
308
- * callback: () => onVisibilityChange(),
309
- * });
310
- * // Cleanup:
311
- * sub.unsubscribe();
312
- * ```
313
- */
314
- declare function fromEventPattern<T>(options: FromEventPatternOptions<T>): Subscription;
315
- //#endregion
316
- //#region src/transport/fetch-transport.d.ts
317
- declare const FetchTransportRedirectKind: {
318
- readonly Follow: "follow";
319
- readonly Manual: "manual";
320
- };
321
- type FetchTransportRedirectKind = (typeof FetchTransportRedirectKind)[keyof typeof FetchTransportRedirectKind];
322
- interface FetchTransportOptions {
323
- /**
324
- * How to handle HTTP redirects.
325
- * - `"follow"`: automatically follow redirects (default fetch behavior)
326
- * - `"manual"`: capture redirect responses as-is (needed for fragment-based protocols)
327
- */
328
- redirect?: FetchTransportRedirectKind;
329
- }
330
- /**
331
- * Default `HttpTransport` backed by the global `fetch` API.
332
- *
333
- * The caller is responsible for ensuring `fetch` is available in the runtime.
334
- * No polyfill is injected — see the polyfill strategy in the design guide.
335
- */
336
- declare function createFetchTransport(options?: FetchTransportOptions): HttpTransport;
337
- //#endregion
338
- //#region src/web/client-environment.d.ts
339
- declare const ClientEnvironmentPreset: {
340
- readonly BrowserPage: "browser_page";
341
- readonly BrowserWorker: "browser_worker";
342
- readonly ServiceWorker: "service_worker";
343
- readonly BrowserExtensionBackground: "browser_extension_background";
344
- };
345
- type ClientEnvironmentPreset = (typeof ClientEnvironmentPreset)[keyof typeof ClientEnvironmentPreset];
346
- interface WebClientEnvironment extends ClientEnvironment {
347
- preset?: ClientEnvironmentPreset;
348
- }
349
- interface PageLocationLike {
350
- href: string;
351
- hash: string;
352
- pathname?: string;
353
- search?: string;
354
- }
355
- interface PageHistoryLike {
356
- replaceState(data: unknown, unused: string, url?: string | URL | null): void;
357
- }
358
- interface PageLocationCapability {
359
- location: PageLocationLike;
360
- }
361
- interface PageLocationHistoryCapability extends PageLocationCapability {
362
- history: PageHistoryLike;
363
- }
364
- interface PageClientEnvironment extends WebClientEnvironment, PageLocationHistoryCapability {}
365
- interface CreateWebClientEnvironmentOptions extends Partial<Omit<ClientEnvironment, "transport">> {
366
- transport?: ClientEnvironment["transport"];
367
- fetchTransport?: FetchTransportOptions;
368
- preset?: ClientEnvironmentPreset;
369
- }
370
- interface CreateBrowserPageClientEnvironmentOptions extends CreateWebClientEnvironmentOptions {
371
- pageCapability?: PageLocationHistoryCapability;
372
- }
373
- interface RequirePageClientEnvironmentOptions {
374
- environment?: WebClientEnvironment | PageClientEnvironment;
375
- pageCapability?: PageLocationHistoryCapability;
376
- }
377
- declare function createWebClientEnvironment(options?: CreateWebClientEnvironmentOptions): WebClientEnvironment;
378
- declare function deriveClientEnvironment(environment: ClientEnvironment): ClientEnvironment;
379
- declare function createBrowserPageClientEnvironment(options?: CreateBrowserPageClientEnvironmentOptions): PageClientEnvironment;
380
- declare function readDefaultPageLocationCapability(): PageLocationCapability | null;
381
- declare function requireDefaultPageLocationCapability(): PageLocationCapability;
382
- declare function createBrowserWorkerClientEnvironment(options?: CreateWebClientEnvironmentOptions): WebClientEnvironment;
383
- declare function createServiceWorkerClientEnvironment(options?: CreateWebClientEnvironmentOptions): WebClientEnvironment;
384
- declare function createBrowserExtensionBackgroundClientEnvironment(options?: CreateWebClientEnvironmentOptions): WebClientEnvironment;
385
- declare function assertResolveEnvironment<T>(environment: T | null | undefined, onResolvingEnvironmentFail: () => never): Exclude<T, null | undefined>;
386
- declare function assertResolveFromEnvironment<TEnvironment, TValue>(environment: TEnvironment | null | undefined, select: (environment: TEnvironment) => TValue | null | undefined, onResolvingCapabilityFail: () => never): Exclude<TValue, null | undefined>;
387
- declare function requirePageClientEnvironment(environmentOrOptions?: PageClientEnvironment | RequirePageClientEnvironmentOptions): PageClientEnvironment;
388
- declare function readDefaultPageLocationHistoryCapability(): PageLocationHistoryCapability | null;
389
- declare function requireDefaultPageLocationHistoryCapability(): PageLocationHistoryCapability;
390
- declare function readPageLocationCapability(input: {
391
- location?: unknown;
392
- }): PageLocationCapability | null;
393
- declare function readPageLocationHistoryCapability(input: {
394
- location?: unknown;
395
- history?: unknown;
396
- }): PageLocationHistoryCapability | null;
397
- declare function assertPageLocationCapability(pageCapability: unknown, fieldName?: string): PageLocationCapability;
398
- declare function assertPageLocationHistoryCapability(pageCapability: unknown, fieldName?: string): PageLocationHistoryCapability;
399
- //#endregion
400
- export { LogEntry as $, createFetchTransport as A, fromEventPattern as B, readPageLocationCapability as C, requirePageClientEnvironment as D, requireDefaultPageLocationHistoryCapability as E, PromiseSettlement as F, timer as G, fromSignal as H, PromiseSettlementKind as I, HttpResponse as J, ClientEnvironment as K, ScheduleAtOptions as L, FromPromiseOptions as M, FromSignalOptions as N, FetchTransportOptions as O, IntervalOptions as P, Scheduler as Q, Subscription as R, readDefaultPageLocationHistoryCapability as S, requireDefaultPageLocationCapability as T, interval as U, fromPromise as V, scheduleAt as W, CancelableHandle as X, HttpTransport as Y, Clock as Z, createBrowserWorkerClientEnvironment as _, PageHistoryLike as a, TraceEvent as at, deriveClientEnvironment as b, PageLocationLike as c, CancellationTokenSourceTrait as ct, assertPageLocationCapability as d, LogLevel as et, assertPageLocationHistoryCapability as f, createBrowserPageClientEnvironment as g, createBrowserExtensionBackgroundClientEnvironment as h, PageClientEnvironment as i, OperationTracerTrait as it, FromEventPatternOptions as j, FetchTransportRedirectKind as k, RequirePageClientEnvironmentOptions as l, CancellationTokenTrait as lt, assertResolveFromEnvironment as m, CreateBrowserPageClientEnvironmentOptions as n, OperationScope as nt, PageLocationCapability as o, TraceEventSinkTrait as ot, assertResolveEnvironment as p, HttpRequest as q, CreateWebClientEnvironmentOptions as r, OperationTraceEventType as rt, PageLocationHistoryCapability as s, CancelableHandle$1 as st, ClientEnvironmentPreset as t, LoggerTrait as tt, WebClientEnvironment as u, DisposableTrait as ut, createServiceWorkerClientEnvironment as v, readPageLocationHistoryCapability as w, readDefaultPageLocationCapability as x, createWebClientEnvironment as y, TimerOptions as z };
401
- //# sourceMappingURL=client-environment-CdHtVxKW.d.mts.map
@@ -1,2 +0,0 @@
1
- import { C as EventSource, D as ReplaySubjectTrait, E as EventSubscriptionTrait, O as RuntimeEventEnvelope, S as EventObserver, T as EventStreamTrait, _ as createEventStream, a as filter, b as fromRxObservable, c as merge, d as shareReplay, f as switchMap, g as withLatestFromSignal, h as throttleTime, i as exhaustMap, k as SubjectTrait, l as pipe, m as tap, n as concatMap, o as finalize, p as takeUntil, r as debounceTime, s as map, t as EventOperator, u as share, v as createReplaySubject, w as EventSourceKind, x as toRxObservable, y as createSubject } from "../index-C4xlKhG7.mjs";
2
- export { EventObserver, EventOperator, EventSource, EventSourceKind, EventStreamTrait, EventSubscriptionTrait, ReplaySubjectTrait, RuntimeEventEnvelope, SubjectTrait, concatMap, createEventStream, createReplaySubject, createSubject, debounceTime, exhaustMap, filter, finalize, fromRxObservable, map, merge, pipe, share, shareReplay, switchMap, takeUntil, tap, throttleTime, toRxObservable, withLatestFromSignal };
@@ -1,2 +0,0 @@
1
- import { _ as createEventStream, a as filter, b as fromRxObservable, c as merge, d as shareReplay, f as switchMap, g as withLatestFromSignal, h as throttleTime, i as exhaustMap, l as pipe, m as tap, n as concatMap, o as finalize, p as takeUntil, r as debounceTime, s as map, t as EventSourceKind, u as share, v as createReplaySubject, x as toRxObservable, y as createSubject } from "../events-BUlfsRfl.mjs";
2
- export { EventSourceKind, concatMap, createEventStream, createReplaySubject, createSubject, debounceTime, exhaustMap, filter, finalize, fromRxObservable, map, merge, pipe, share, shareReplay, switchMap, takeUntil, tap, throttleTime, toRxObservable, withLatestFromSignal };