@fireweaveai/web-sdk 2.1.0

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 (49) hide show
  1. package/dist/adapter.d.ts +87 -0
  2. package/dist/adapter.d.ts.map +1 -0
  3. package/dist/adapter.js +2 -0
  4. package/dist/adapter.js.map +1 -0
  5. package/dist/adapters/inmemory.d.ts +51 -0
  6. package/dist/adapters/inmemory.d.ts.map +1 -0
  7. package/dist/adapters/inmemory.js +91 -0
  8. package/dist/adapters/inmemory.js.map +1 -0
  9. package/dist/adapters/local.d.ts +38 -0
  10. package/dist/adapters/local.d.ts.map +1 -0
  11. package/dist/adapters/local.js +51 -0
  12. package/dist/adapters/local.js.map +1 -0
  13. package/dist/adapters/remote.d.ts +45 -0
  14. package/dist/adapters/remote.d.ts.map +1 -0
  15. package/dist/adapters/remote.js +332 -0
  16. package/dist/adapters/remote.js.map +1 -0
  17. package/dist/client.d.ts +134 -0
  18. package/dist/client.d.ts.map +1 -0
  19. package/dist/client.js +0 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/context.d.ts +26 -0
  22. package/dist/context.d.ts.map +1 -0
  23. package/dist/context.js +106 -0
  24. package/dist/context.js.map +1 -0
  25. package/dist/errors.d.ts +37 -0
  26. package/dist/errors.d.ts.map +1 -0
  27. package/dist/errors.js +93 -0
  28. package/dist/errors.js.map +1 -0
  29. package/dist/hosts.d.ts +11 -0
  30. package/dist/hosts.d.ts.map +1 -0
  31. package/dist/hosts.js +79 -0
  32. package/dist/hosts.js.map +1 -0
  33. package/dist/index.d.ts +45 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +35 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/provider.d.ts +39 -0
  38. package/dist/provider.d.ts.map +1 -0
  39. package/dist/provider.js +93 -0
  40. package/dist/provider.js.map +1 -0
  41. package/dist/runtime.d.ts +62 -0
  42. package/dist/runtime.d.ts.map +1 -0
  43. package/dist/runtime.js +289 -0
  44. package/dist/runtime.js.map +1 -0
  45. package/dist/types.d.ts +90 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +10 -0
  48. package/dist/types.js.map +1 -0
  49. package/package.json +45 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Backend adapter boundary for the browser.
3
+ *
4
+ * One shape differs from the server port, and it is the difference that makes
5
+ * a synchronous OpenFeature provider possible: the server port has
6
+ * `resolve(flagKey)` — one call per control point — while this port has
7
+ * `prefetch(context)`, which returns EVERY decision for a context in one round
8
+ * trip. Evaluation then becomes a synchronous map lookup in the runtime.
9
+ *
10
+ * The reason is not performance, it is the OpenFeature web contract:
11
+ * `resolve*Evaluation` must return `ResolutionDetails`, not a Promise. Anything
12
+ * the provider needs at read time must already be in memory.
13
+ *
14
+ * Adapters translate canonical requests to the Fireweave remote protocol; they
15
+ * never see OpenFeature types.
16
+ */
17
+ import type { CanonicalContext, DecisionReason, Exposure, FlagValueType, JsonValue, Signal } from './types.js';
18
+ import type { FireweaveError } from './errors.js';
19
+ export interface AdapterResolution {
20
+ found: boolean;
21
+ enabled?: boolean;
22
+ value?: JsonValue;
23
+ variant?: string;
24
+ flagType?: FlagValueType;
25
+ reason?: DecisionReason;
26
+ reasonCode?: string;
27
+ version?: number;
28
+ payload?: JsonValue;
29
+ quotaLimited?: boolean;
30
+ }
31
+ /** Every decision the backend returned for one context, keyed by control point. */
32
+ export type PrefetchResult = ReadonlyMap<string, AdapterResolution>;
33
+ export interface PrefetchOptions {
34
+ /** Restrict the batch to these keys; omit to let the backend return all it knows. */
35
+ readonly flagKeys?: readonly string[];
36
+ readonly signal?: AbortSignal;
37
+ }
38
+ export type TargetKind = 'user' | 'device';
39
+ export interface RegisterTargetOptions {
40
+ readonly kind?: TargetKind;
41
+ readonly properties?: Record<string, JsonValue>;
42
+ readonly environment?: string;
43
+ readonly signal?: AbortSignal;
44
+ }
45
+ export interface RegisterTargetResult {
46
+ /**
47
+ * `false` means the target was NOT registered — rules depending on its
48
+ * properties will not match until a later attempt succeeds. Sign-in paths
49
+ * normally ignore this; a careful caller logs it, because a silently
50
+ * unregistered target is exactly how targeting ends up matching nobody.
51
+ */
52
+ readonly ok: boolean;
53
+ readonly error?: FireweaveError;
54
+ }
55
+ export interface AdapterRuntimeFeatures {
56
+ remoteEvaluation?: boolean;
57
+ /** Always false in the browser, structurally — see ADR-0009. */
58
+ localEvaluation?: boolean;
59
+ localOnly?: boolean;
60
+ exposureEmission?: boolean;
61
+ sideEffectFreeReads?: boolean;
62
+ groupAnalytics?: boolean;
63
+ }
64
+ export interface WebBackendAdapter {
65
+ readonly name: 'fireweave' | 'inmemory' | 'other';
66
+ /** Bring the backend to a usable state. Reject with FireweaveError on failure. */
67
+ initialize(signal?: AbortSignal): Promise<void>;
68
+ /** Fetch every decision for a context. Throws FireweaveError on transport faults. */
69
+ prefetch(context: CanonicalContext, options?: PrefetchOptions): Promise<PrefetchResult>;
70
+ /** Register a user or device for durable targeting. Resolves rather than throws. */
71
+ registerTarget?(targetingKey: string, options?: RegisterTargetOptions): Promise<RegisterTargetResult>;
72
+ recordExposure?(exposure: Exposure): void;
73
+ recordSignal?(signal: Signal): void;
74
+ /**
75
+ * Deliver queued telemetry.
76
+ *
77
+ * `beacon: true` asks for an unload-safe transport (`sendBeacon` /
78
+ * `keepalive`) because the page may be seconds from gone. Delivery is
79
+ * best-effort by definition on that path — neither transport reports failure.
80
+ */
81
+ flush?(options?: {
82
+ beacon?: boolean;
83
+ }): Promise<void>;
84
+ shutdown(): Promise<void>;
85
+ features(): AdapterRuntimeFeatures;
86
+ }
87
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EA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C;IAC3B,gEAAgE;IAChE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;IAClD,kFAAkF;IAClF,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACxF,oFAAoF;IACpF,cAAc,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtG,cAAc,CAAC,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1C,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,IAAI,sBAAsB,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * In-memory adapter — offline evaluation for tests and conformance fixtures.
3
+ *
4
+ * Declares control points up front and serves them from memory. Fault
5
+ * injection exists so the conformance suite can drive the error taxonomy
6
+ * without a network or a stub server.
7
+ */
8
+ import { type FireweaveErrorKind } from '../errors.js';
9
+ import type { AdapterResolution, AdapterRuntimeFeatures, PrefetchOptions, PrefetchResult, WebBackendAdapter } from '../adapter.js';
10
+ import type { CanonicalContext, Exposure, FlagValueType, JsonValue, Signal } from '../types.js';
11
+ export interface InMemoryFlagDefinition {
12
+ readonly type: FlagValueType;
13
+ readonly enabled: boolean;
14
+ readonly value: JsonValue;
15
+ readonly variant?: string;
16
+ readonly payload?: JsonValue;
17
+ /** Only resolve for this targeting key; otherwise the control point misses. */
18
+ readonly matchTargetingKey?: string;
19
+ readonly fireweaveReason?: AdapterResolution['reason'];
20
+ }
21
+ export interface InMemoryFault {
22
+ readonly kind: FireweaveErrorKind;
23
+ /** Throw on initialize rather than on prefetch. */
24
+ readonly onInitialize?: boolean;
25
+ }
26
+ export interface InMemoryWebAdapterOptions {
27
+ readonly flags?: Record<string, InMemoryFlagDefinition>;
28
+ readonly fault?: InMemoryFault;
29
+ }
30
+ export declare class InMemoryWebAdapter implements WebBackendAdapter {
31
+ readonly name: "inmemory";
32
+ private flags;
33
+ private fault;
34
+ private readonly exposures;
35
+ private readonly signals;
36
+ private closed;
37
+ constructor(options?: InMemoryWebAdapterOptions);
38
+ setFlags(flags: Record<string, InMemoryFlagDefinition>): void;
39
+ setFault(fault: InMemoryFault | undefined): void;
40
+ initialize(_signal?: AbortSignal): Promise<void>;
41
+ prefetch(context: CanonicalContext, options?: PrefetchOptions): Promise<PrefetchResult>;
42
+ recordExposure(exposure: Exposure): void;
43
+ getExposures(): readonly Exposure[];
44
+ recordSignal(signal: Signal): void;
45
+ getSignals(): readonly Signal[];
46
+ flush(): Promise<void>;
47
+ shutdown(): Promise<void>;
48
+ isClosed(): boolean;
49
+ features(): AdapterRuntimeFeatures;
50
+ }
51
+ //# sourceMappingURL=inmemory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,GAAE,yBAA8B;IAKnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI;IAI7D,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAI1C,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IA0B7F,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIxC,YAAY,IAAI,SAAS,QAAQ,EAAE;IAInC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIlC,UAAU,IAAI,SAAS,MAAM,EAAE;IAIzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,QAAQ,IAAI,OAAO;IAInB,QAAQ,IAAI,sBAAsB;CAUnC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * In-memory adapter — offline evaluation for tests and conformance fixtures.
3
+ *
4
+ * Declares control points up front and serves them from memory. Fault
5
+ * injection exists so the conformance suite can drive the error taxonomy
6
+ * without a network or a stub server.
7
+ */
8
+ import { FireweaveError } from '../errors.js';
9
+ export class InMemoryWebAdapter {
10
+ name = 'inmemory';
11
+ flags;
12
+ fault;
13
+ exposures = [];
14
+ signals = [];
15
+ closed = false;
16
+ constructor(options = {}) {
17
+ this.flags = new Map(Object.entries(options.flags ?? {}));
18
+ this.fault = options.fault;
19
+ }
20
+ setFlags(flags) {
21
+ this.flags = new Map(Object.entries(flags));
22
+ }
23
+ setFault(fault) {
24
+ this.fault = fault;
25
+ }
26
+ async initialize(_signal) {
27
+ if (this.fault?.onInitialize === true)
28
+ throw new FireweaveError(this.fault.kind);
29
+ }
30
+ async prefetch(context, options) {
31
+ if (this.fault !== undefined && this.fault.onInitialize !== true) {
32
+ throw new FireweaveError(this.fault.kind);
33
+ }
34
+ const wanted = options?.flagKeys;
35
+ const out = new Map();
36
+ for (const [key, def] of this.flags) {
37
+ if (wanted !== undefined && wanted.length > 0 && !wanted.includes(key))
38
+ continue;
39
+ if (def.matchTargetingKey !== undefined && context.targetingKey !== def.matchTargetingKey) {
40
+ out.set(key, { found: false });
41
+ continue;
42
+ }
43
+ const resolution = {
44
+ found: true,
45
+ enabled: def.enabled,
46
+ value: def.value,
47
+ flagType: def.type,
48
+ };
49
+ if (def.variant !== undefined)
50
+ resolution.variant = def.variant;
51
+ if (def.payload !== undefined)
52
+ resolution.payload = def.payload;
53
+ if (def.fireweaveReason !== undefined)
54
+ resolution.reason = def.fireweaveReason;
55
+ out.set(key, resolution);
56
+ }
57
+ return out;
58
+ }
59
+ recordExposure(exposure) {
60
+ this.exposures.push(exposure);
61
+ }
62
+ getExposures() {
63
+ return this.exposures;
64
+ }
65
+ recordSignal(signal) {
66
+ this.signals.push(signal);
67
+ }
68
+ getSignals() {
69
+ return this.signals;
70
+ }
71
+ async flush() {
72
+ // no-op: telemetry stays queryable for tests
73
+ }
74
+ async shutdown() {
75
+ this.closed = true;
76
+ }
77
+ isClosed() {
78
+ return this.closed;
79
+ }
80
+ features() {
81
+ return {
82
+ remoteEvaluation: false,
83
+ localEvaluation: false,
84
+ localOnly: true,
85
+ exposureEmission: true,
86
+ sideEffectFreeReads: true,
87
+ groupAnalytics: false,
88
+ };
89
+ }
90
+ }
91
+ //# sourceMappingURL=inmemory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inmemory.js","sourceRoot":"","sources":["../../src/adapters/inmemory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAA2B,MAAM,cAAc,CAAC;AAgCvE,MAA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CAA6C;IAC/C,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO;YACL,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,KAAK;YACtB,SAAS,EAAE,IAAI;YACf,gBAAgB,EAAE,IAAI;YACtB,mBAAmB,EAAE,IAAI;YACzB,cAAc,EAAE,KAAK;SACtB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Local development adapter for the browser — the DEV substrate of a
3
+ * scaffolded web harness, and the exact peer of the server SDK's
4
+ * `FireweaveLocalAdapter`.
5
+ *
6
+ * A key present in `devFlags` resolves with reason `STATIC`; every other key
7
+ * misses, which the runtime turns into the caller's own default. No network,
8
+ * no credentials, nothing to configure.
9
+ *
10
+ * Call-site defaults stay `false` under RAMP-1. Never write `flag(key, true)`
11
+ * to dogfood locally — that same `true` is the production fallback when a
12
+ * control point is absent from the provider, so it silently ships the ON
13
+ * branch. Use `devFlags`.
14
+ */
15
+ import type { AdapterRuntimeFeatures, PrefetchOptions, PrefetchResult, WebBackendAdapter } from '../adapter.js';
16
+ import type { CanonicalContext } from '../types.js';
17
+ export interface FireweaveLocalWebAdapterOptions {
18
+ readonly devFlags?: Record<string, boolean>;
19
+ }
20
+ export declare class FireweaveLocalWebAdapter implements WebBackendAdapter {
21
+ /** Not `inmemory` — that name belongs to the fixture adapter. */
22
+ readonly name: "other";
23
+ private readonly devFlags;
24
+ private closed;
25
+ constructor(options?: FireweaveLocalWebAdapterOptions);
26
+ initialize(_signal?: AbortSignal): Promise<void>;
27
+ /**
28
+ * `enabled: true` alongside `reason: 'STATIC'` is deliberate: reporting
29
+ * `enabled: false` for an override of `false` would make the runtime label
30
+ * the decision `DISABLED`, which means "exists but switched off upstream" —
31
+ * not what a local override expresses.
32
+ */
33
+ prefetch(_context: CanonicalContext, _options?: PrefetchOptions): Promise<PrefetchResult>;
34
+ shutdown(): Promise<void>;
35
+ isClosed(): boolean;
36
+ features(): AdapterRuntimeFeatures;
37
+ }
38
+ //# sourceMappingURL=local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/adapters/local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAEV,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,qBAAa,wBAAyB,YAAW,iBAAiB;IAChE,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IACnD,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,GAAE,+BAAoC;IAInD,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD;;;;;OAKG;IACG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAezF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,QAAQ,IAAI,OAAO;IAInB,QAAQ,IAAI,sBAAsB;CAYnC"}
@@ -0,0 +1,51 @@
1
+ export class FireweaveLocalWebAdapter {
2
+ /** Not `inmemory` — that name belongs to the fixture adapter. */
3
+ name = 'other';
4
+ devFlags;
5
+ closed = false;
6
+ constructor(options = {}) {
7
+ this.devFlags = { ...(options.devFlags ?? {}) };
8
+ }
9
+ async initialize(_signal) {
10
+ // Nothing to connect to.
11
+ }
12
+ /**
13
+ * `enabled: true` alongside `reason: 'STATIC'` is deliberate: reporting
14
+ * `enabled: false` for an override of `false` would make the runtime label
15
+ * the decision `DISABLED`, which means "exists but switched off upstream" —
16
+ * not what a local override expresses.
17
+ */
18
+ async prefetch(_context, _options) {
19
+ const out = new Map();
20
+ for (const [key, value] of Object.entries(this.devFlags)) {
21
+ out.set(key, {
22
+ found: true,
23
+ enabled: true,
24
+ value,
25
+ variant: value ? 'on' : 'off',
26
+ reason: 'STATIC',
27
+ flagType: 'boolean',
28
+ });
29
+ }
30
+ return out;
31
+ }
32
+ async shutdown() {
33
+ this.closed = true;
34
+ }
35
+ isClosed() {
36
+ return this.closed;
37
+ }
38
+ features() {
39
+ return {
40
+ remoteEvaluation: false,
41
+ localEvaluation: true,
42
+ localOnly: true,
43
+ // No exposure sink exists locally; claiming otherwise would advertise
44
+ // emission that silently goes nowhere.
45
+ exposureEmission: false,
46
+ sideEffectFreeReads: true,
47
+ groupAnalytics: false,
48
+ };
49
+ }
50
+ }
51
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/adapters/local.ts"],"names":[],"mappings":"AA2BA,MAAM,OAAO,wBAAwB;IACnC,iEAAiE;IACxD,IAAI,GAAG,OAAgB,CAAC;IAEhB,QAAQ,CAA0B;IAC3C,MAAM,GAAG,KAAK,CAAC;IAEvB,YAAY,UAA2C,EAAE;QACvD,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAqB;QACpC,yBAAyB;IAC3B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,QAA0B,EAAE,QAA0B;QACnE,MAAM,GAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;QACjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;gBACX,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,IAAI;gBACb,KAAK;gBACL,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAC7B,MAAM,EAAE,QAAQ;gBAChB,QAAQ,EAAE,SAAS;aACpB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO;YACL,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,IAAI;YACrB,SAAS,EAAE,IAAI;YACf,sEAAsE;YACtE,uCAAuC;YACvC,gBAAgB,EAAE,KAAK;YACvB,mBAAmB,EAAE,IAAI;YACzB,cAAc,EAAE,KAAK;SACtB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,45 @@
1
+ import type { AdapterRuntimeFeatures, PrefetchOptions, PrefetchResult, RegisterTargetOptions, RegisterTargetResult, WebBackendAdapter } from '../adapter.js';
2
+ import type { CanonicalContext, Exposure, Signal } from '../types.js';
3
+ export type FireweaveFetchLike = typeof fetch;
4
+ export interface FireweaveRemoteWebAdapterOptions {
5
+ /** fw-server base URL, e.g. `https://app-server.fireweave.ai`. */
6
+ readonly apiUrl: string;
7
+ /** Fireweave project key. Public by construction — must be scoped accordingly. */
8
+ readonly apiKey: string;
9
+ /** SSRF/misconfiguration allowlist override. `['*']` opts out. */
10
+ readonly allowedHosts?: readonly string[];
11
+ readonly requestTimeoutMs?: number;
12
+ /** Injected fetch (tests). Defaults to the global. */
13
+ readonly fetch?: FireweaveFetchLike;
14
+ }
15
+ export declare class FireweaveRemoteWebAdapter implements WebBackendAdapter {
16
+ readonly name: "fireweave";
17
+ private readonly apiUrl;
18
+ private readonly apiKey;
19
+ private readonly allowedHosts;
20
+ private readonly requestTimeoutMs;
21
+ private readonly fetchImpl;
22
+ private readonly pending;
23
+ private ready;
24
+ private closed;
25
+ constructor(options: FireweaveRemoteWebAdapterOptions);
26
+ initialize(_signal?: AbortSignal): Promise<void>;
27
+ prefetch(context: CanonicalContext, options?: PrefetchOptions): Promise<PrefetchResult>;
28
+ registerTarget(targetingKey: string, options?: RegisterTargetOptions): Promise<RegisterTargetResult>;
29
+ recordExposure(exposure: Exposure): void;
30
+ recordSignal(signal: Signal): void;
31
+ /**
32
+ * `beacon: true` is the unload path. It must not await anything the browser
33
+ * will cancel, so it uses `sendBeacon` when available and a `keepalive`
34
+ * fetch otherwise, and it never re-queues on failure — there is no later.
35
+ */
36
+ flush(options?: {
37
+ beacon?: boolean;
38
+ }): Promise<void>;
39
+ private sendBeaconOrKeepalive;
40
+ shutdown(): Promise<void>;
41
+ features(): AdapterRuntimeFeatures;
42
+ private toResolution;
43
+ private requestJson;
44
+ }
45
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/adapters/remote.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAEV,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAkB,QAAQ,EAAa,MAAM,EAAE,MAAM,aAAa,CAAC;AAQjG,MAAM,MAAM,kBAAkB,GAAG,OAAO,KAAK,CAAC;AAE9C,MAAM,WAAW,gCAAgC;IAC/C,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,MAAM,C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