@fireweaveai/web-sdk 2.3.0-staging.2 → 3.0.0-staging.1
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.
- package/README.md +100 -4
- package/dist/application/client.d.ts +12 -27
- package/dist/application/client.d.ts.map +1 -1
- package/dist/application/client.js +21 -38
- package/dist/application/client.js.map +1 -1
- package/dist/application/ports.d.ts +4 -4
- package/dist/application/ports.d.ts.map +1 -1
- package/dist/application/runtime.d.ts +2 -2
- package/dist/application/runtime.d.ts.map +1 -1
- package/dist/application/runtime.js +22 -19
- package/dist/application/runtime.js.map +1 -1
- package/dist/build/node/define.d.ts +14 -0
- package/dist/build/node/define.js +35 -0
- package/dist/build/node/define.js.map +1 -0
- package/dist/build/node/shared.d.ts +19 -0
- package/dist/build/node/shared.js +44 -0
- package/dist/build/node/shared.js.map +1 -0
- package/dist/build/node/vite.d.ts +53 -0
- package/dist/build/node/vite.js +103 -0
- package/dist/build/node/vite.js.map +1 -0
- package/dist/build/src/start/build-info.d.ts +2 -0
- package/dist/build/src/start/build-info.js +7 -0
- package/dist/build/src/start/build-info.js.map +1 -0
- package/dist/build/src/start/names.d.ts +44 -0
- package/dist/build/src/start/names.js +45 -0
- package/dist/build/src/start/names.js.map +1 -0
- package/dist/build/src/start/policy.d.ts +70 -0
- package/dist/build/src/start/policy.js +124 -0
- package/dist/build/src/start/policy.js.map +1 -0
- package/dist/domain/errors.d.ts +1 -1
- package/dist/domain/errors.d.ts.map +1 -1
- package/dist/domain/errors.js +1 -1
- package/dist/domain/errors.js.map +1 -1
- package/dist/domain/types.d.ts +3 -3
- package/dist/domain/types.d.ts.map +1 -1
- package/dist/domain/validation.d.ts +4 -4
- package/dist/domain/validation.js +7 -7
- package/dist/domain/validation.js.map +1 -1
- package/dist/infrastructure/adapters/inmemory.js +1 -1
- package/dist/infrastructure/adapters/inmemory.js.map +1 -1
- package/dist/infrastructure/adapters/remote.js +11 -11
- package/dist/infrastructure/adapters/remote.js.map +1 -1
- package/dist/start/build-info.d.ts +3 -0
- package/dist/start/build-info.d.ts.map +1 -0
- package/dist/start/build-info.js +7 -0
- package/dist/start/build-info.js.map +1 -0
- package/dist/start/control-points.d.ts +25 -0
- package/dist/start/control-points.d.ts.map +1 -0
- package/dist/start/control-points.js +57 -0
- package/dist/start/control-points.js.map +1 -0
- package/dist/start/fw.d.ts +43 -0
- package/dist/start/fw.d.ts.map +1 -0
- package/dist/start/fw.js +135 -0
- package/dist/start/fw.js.map +1 -0
- package/dist/start/identity.d.ts +20 -0
- package/dist/start/identity.d.ts.map +1 -0
- package/dist/start/identity.js +85 -0
- package/dist/start/identity.js.map +1 -0
- package/dist/start/index.d.ts +35 -0
- package/dist/start/index.d.ts.map +1 -0
- package/dist/start/index.js +30 -0
- package/dist/start/index.js.map +1 -0
- package/dist/start/names.d.ts +45 -0
- package/dist/start/names.d.ts.map +1 -0
- package/dist/start/names.js +45 -0
- package/dist/start/names.js.map +1 -0
- package/dist/start/policy.d.ts +71 -0
- package/dist/start/policy.d.ts.map +1 -0
- package/dist/start/policy.js +124 -0
- package/dist/start/policy.js.map +1 -0
- package/dist/start/state.d.ts +104 -0
- package/dist/start/state.d.ts.map +1 -0
- package/dist/start/state.js +361 -0
- package/dist/start/state.js.map +1 -0
- package/package.json +23 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fireweaveai/web-sdk/define — the start profile's build check for bundlers
|
|
3
|
+
* other than Vite (Next.js, webpack, esbuild, Rollup). No vite import.
|
|
4
|
+
*
|
|
5
|
+
* // next.config.mjs (or any build config)
|
|
6
|
+
* import { fireweaveDefine } from '@fireweaveai/web-sdk/define';
|
|
7
|
+
* const define = fireweaveDefine(); // throws if the build would ship without a usable key
|
|
8
|
+
* // webpack: new webpack.DefinePlugin(define) · esbuild: { define } · Rollup: replace({ values: define })
|
|
9
|
+
*
|
|
10
|
+
* Reads process.env only: FIREWEAVE_BROWSER_KEY (or `keyVariable`),
|
|
11
|
+
* FIREWEAVE_URL, and the environment name FIREWEAVE_ENV, then APP_ENV, then
|
|
12
|
+
* NODE_ENV. Same policy and messages as the Vite plugin.
|
|
13
|
+
*/
|
|
14
|
+
import { BUILD_ENV, ENVIRONMENT_FALLBACK, INJECTED_CONFIG_NAME } from '../src/start/names.js';
|
|
15
|
+
import { sourced } from '../src/start/policy.js';
|
|
16
|
+
import { resolveBuild, summaryLine } from './shared.js';
|
|
17
|
+
function resolveFromEnv(options) {
|
|
18
|
+
const env = options.env ?? process.env;
|
|
19
|
+
const lookup = (name) => sourced(env[name], name);
|
|
20
|
+
const resolved = resolveBuild(options, lookup, options.keyVariable ?? BUILD_ENV.key, [BUILD_ENV.environment, ENVIRONMENT_FALLBACK, 'NODE_ENV']);
|
|
21
|
+
const log = options.log ?? ((line) => console.info(line));
|
|
22
|
+
for (const w of resolved.warnings)
|
|
23
|
+
log(w);
|
|
24
|
+
log(summaryLine(resolved.config));
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
27
|
+
/** Fail the build (throw) when the start profile would not start; returns the resolved config. */
|
|
28
|
+
export function assertFireweaveBuild(options = {}) {
|
|
29
|
+
return resolveFromEnv(options).config;
|
|
30
|
+
}
|
|
31
|
+
/** assertFireweaveBuild, plus the define map that hands the result to start(). */
|
|
32
|
+
export function fireweaveDefine(options = {}) {
|
|
33
|
+
return { [INJECTED_CONFIG_NAME]: JSON.stringify(resolveFromEnv(options).injected) };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../node/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AAW3E,SAAS,cAAc,CAAC,OAA+B;IACrD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,IAAI,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC;IAChJ,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ;QAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1C,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,oBAAoB,CAAC,UAAkC,EAAE;IACvE,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AACxC,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,eAAe,CAAC,UAAkC,EAAE;IAClE,OAAO,EAAE,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type InjectedConfig, type PolicyConfig, type Sourced } from '../src/start/policy.js';
|
|
2
|
+
/** A variable read at build time: its value and a source label for logs (never the value). */
|
|
3
|
+
export type EnvLookup = (name: string) => Sourced | undefined;
|
|
4
|
+
export interface BuildOptions {
|
|
5
|
+
/** Browser key. Prefer FIREWEAVE_BROWSER_KEY in the build environment. */
|
|
6
|
+
readonly key?: string;
|
|
7
|
+
/** fw-server URL or a same-origin proxy path ('/fw'). Default: FIREWEAVE_URL, else the SDK channel host. */
|
|
8
|
+
readonly url?: string;
|
|
9
|
+
/** Environment name for the mode rule. Default: FIREWEAVE_ENV, else APP_ENV. */
|
|
10
|
+
readonly environment?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface BuildResolution {
|
|
13
|
+
readonly config: PolicyConfig;
|
|
14
|
+
readonly injected: InjectedConfig;
|
|
15
|
+
readonly warnings: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function resolveBuild(options: BuildOptions, lookup: EnvLookup, keyVariable: string, environmentNames: readonly string[], extraEnvironment?: Sourced): BuildResolution;
|
|
18
|
+
/** One summary line for build output. Names sources, never values. */
|
|
19
|
+
export declare function summaryLine(config: PolicyConfig): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time resolution shared by the Vite plugin and the define helper.
|
|
3
|
+
* Runs in Node at config time, never in a browser. It reuses the browser's
|
|
4
|
+
* own policy (src/start/policy.ts), so a build fails for exactly the reasons
|
|
5
|
+
* the page would.
|
|
6
|
+
*/
|
|
7
|
+
import { SDK_CHANNEL } from '../src/start/build-info.js';
|
|
8
|
+
import { BUILD_ENV, RETIRED_KEY_NAMES } from '../src/start/names.js';
|
|
9
|
+
import { firstOf, resolvePolicy, sourced } from '../src/start/policy.js';
|
|
10
|
+
export function resolveBuild(options, lookup, keyVariable, environmentNames, extraEnvironment) {
|
|
11
|
+
const key = firstOf(sourced(options.key, 'fireweave({ key })'), lookup(keyVariable));
|
|
12
|
+
const url = firstOf(sourced(options.url, 'fireweave({ url })'), lookup(BUILD_ENV.url));
|
|
13
|
+
const environment = firstOf(sourced(options.environment, 'fireweave({ environment })'), ...environmentNames.map((name) => lookup(name)), extraEnvironment);
|
|
14
|
+
const warnings = [];
|
|
15
|
+
if (key === undefined) {
|
|
16
|
+
for (const name of RETIRED_KEY_NAMES) {
|
|
17
|
+
if (lookup(name) !== undefined) {
|
|
18
|
+
warnings.push(`[fireweave] ${name} is not read by the start profile: it held a server-family key. Create a browser key (fw_public_…) and set ${keyVariable}.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const checked = [`fireweave({ environment })`, ...environmentNames, ...(extraEnvironment !== undefined ? [extraEnvironment.source] : [])].join(', ');
|
|
23
|
+
const policy = resolvePolicy({ key, url, environment, channel: SDK_CHANNEL, keyVariable, environmentChecked: checked });
|
|
24
|
+
if (!policy.ok)
|
|
25
|
+
throw new Error(policy.message);
|
|
26
|
+
const config = policy.config;
|
|
27
|
+
const injected = {
|
|
28
|
+
v: 1,
|
|
29
|
+
...(config.mode === 'remote' && key !== undefined ? { key: key.value, keySource: key.source } : {}),
|
|
30
|
+
...(url !== undefined ? { url: url.value, urlSource: url.source } : {}),
|
|
31
|
+
...(environment !== undefined ? { environment: environment.value, environmentSource: environment.source } : {}),
|
|
32
|
+
};
|
|
33
|
+
return { config, injected, warnings: [...warnings, ...policy.warnings] };
|
|
34
|
+
}
|
|
35
|
+
/** One summary line for build output. Names sources, never values. */
|
|
36
|
+
export function summaryLine(config) {
|
|
37
|
+
if (config.mode === 'local') {
|
|
38
|
+
const why = config.modeSource === 'environment' ? `environment '${config.environment ?? ''}' from ${config.environmentSource ?? ''}` : 'mode option';
|
|
39
|
+
return `[fireweave] local mode (${why}): values come from your control-points object; nothing is sent to fw-server.`;
|
|
40
|
+
}
|
|
41
|
+
const host = config.url !== undefined && !config.url.startsWith('/') ? new URL(config.url).host : config.url;
|
|
42
|
+
return `[fireweave] remote mode: browser key from ${config.keySource}, fw-server ${host} (${config.urlSource ?? ''}).`;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,KAAK,aAAa,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,WAAW,IAAI,EAAE,UAAU,MAAM,CAAC,iBAAiB,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;QACrJ,OAAO,2BAA2B,GAAG,+EAA+E,CAAC;IACvH,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAC7G,OAAO,6CAA6C,MAAM,CAAC,SAAS,eAAe,IAAI,KAAK,MAAM,CAAC,SAAS,IAAI,EAAE,IAAI,CAAC;AACzH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type BuildOptions } from './shared.js';
|
|
2
|
+
export type FireweavePluginOptions = BuildOptions;
|
|
3
|
+
/** The subset of Vite's types the plugin touches, so the package needs no vite types to build. */
|
|
4
|
+
interface UserConfigLike {
|
|
5
|
+
readonly root?: string;
|
|
6
|
+
readonly envDir?: string | false;
|
|
7
|
+
readonly build?: {
|
|
8
|
+
readonly lib?: unknown;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface ConfigEnvLike {
|
|
12
|
+
readonly command: 'serve' | 'build';
|
|
13
|
+
readonly mode: string;
|
|
14
|
+
readonly isPreview?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ResolvedConfigLike {
|
|
17
|
+
readonly envPrefix?: string | readonly string[];
|
|
18
|
+
readonly build?: {
|
|
19
|
+
readonly ssr?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
type OutputFileLike = {
|
|
23
|
+
readonly type: 'chunk';
|
|
24
|
+
readonly code: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: 'asset';
|
|
27
|
+
readonly source: string | Uint8Array;
|
|
28
|
+
};
|
|
29
|
+
interface PluginContextLike {
|
|
30
|
+
readonly environment?: {
|
|
31
|
+
readonly config?: {
|
|
32
|
+
readonly consumer?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export type LoadEnv = (mode: string, envDir: string, prefixes: string[]) => Record<string, string> | Promise<Record<string, string>>;
|
|
37
|
+
export interface FireweaveVitePlugin {
|
|
38
|
+
readonly name: 'fireweave';
|
|
39
|
+
readonly enforce: 'pre';
|
|
40
|
+
config(userConfig: UserConfigLike, env: ConfigEnvLike): Promise<Record<string, unknown> | undefined>;
|
|
41
|
+
configResolved(config: ResolvedConfigLike): void;
|
|
42
|
+
generateBundle(this: PluginContextLike, options: unknown, bundle: Readonly<Record<string, OutputFileLike>>): void;
|
|
43
|
+
}
|
|
44
|
+
/** Test seam: the env-file loader and the process environment. */
|
|
45
|
+
export interface PluginDeps {
|
|
46
|
+
readonly loadEnv?: LoadEnv;
|
|
47
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
48
|
+
readonly log?: (line: string) => void;
|
|
49
|
+
}
|
|
50
|
+
export declare function createFireweavePlugin(options?: FireweavePluginOptions, deps?: PluginDeps): FireweaveVitePlugin;
|
|
51
|
+
/** The fireweave() Vite plugin. Add it to `plugins` in vite.config.ts (or a framework's `vite.plugins`). */
|
|
52
|
+
export declare function fireweave(options?: FireweavePluginOptions): FireweaveVitePlugin;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fireweaveai/web-sdk/vite — the fireweave() Vite plugin.
|
|
3
|
+
*
|
|
4
|
+
* // vite.config.ts
|
|
5
|
+
* import { fireweave } from '@fireweaveai/web-sdk/vite';
|
|
6
|
+
* export default defineConfig({ plugins: [fireweave()] });
|
|
7
|
+
*
|
|
8
|
+
* At config time (Node) it reads FIREWEAVE_BROWSER_KEY, FIREWEAVE_URL and the
|
|
9
|
+
* environment name from the process environment and Vite's env files, applies
|
|
10
|
+
* the start profile's policy, and either fails the dev server or build with a
|
|
11
|
+
* message naming the variable, or injects the result as
|
|
12
|
+
* __FIREWEAVE_WEB_CONFIG__ for start() to pick up. After a client build it
|
|
13
|
+
* fails if a server key reached any output file.
|
|
14
|
+
*
|
|
15
|
+
* Environment name: FIREWEAVE_ENV, then APP_ENV; the dev server and Vitest
|
|
16
|
+
* also fall back to Vite's mode. A build never infers local mode from
|
|
17
|
+
* `--mode development`, so a production build without a key fails.
|
|
18
|
+
*
|
|
19
|
+
* Node build tooling: nothing here ships to the browser. vite is an optional
|
|
20
|
+
* peer and is loaded lazily, so this file has no static import of it.
|
|
21
|
+
*/
|
|
22
|
+
import { resolve as resolvePath } from 'node:path';
|
|
23
|
+
import { BUILD_ENV, ENVIRONMENT_FALLBACK, INJECTED_CONFIG_NAME, SERVER_KEY_NAMES } from '../src/start/names.js';
|
|
24
|
+
import { sourced } from '../src/start/policy.js';
|
|
25
|
+
import { resolveBuild, summaryLine } from './shared.js';
|
|
26
|
+
const ENV_PREFIXES = ['FIREWEAVE_', ENVIRONMENT_FALLBACK, 'VITE_FW_', 'PUBLIC_FW_'];
|
|
27
|
+
const SERVER_KEY_PATTERN = /project-api-key_[A-Za-z0-9_-]{8,}/;
|
|
28
|
+
async function viteLoadEnv() {
|
|
29
|
+
const specifier = 'vite';
|
|
30
|
+
const vite = (await import(specifier));
|
|
31
|
+
return vite.loadEnv;
|
|
32
|
+
}
|
|
33
|
+
/** Mirror Vite's env-file location: envDir resolved against the resolved root; false disables files. */
|
|
34
|
+
function envDirOf(userConfig) {
|
|
35
|
+
if (userConfig.envDir === false)
|
|
36
|
+
return false;
|
|
37
|
+
const root = resolvePath(userConfig.root ?? process.cwd());
|
|
38
|
+
return userConfig.envDir !== undefined ? resolvePath(root, userConfig.envDir) : root;
|
|
39
|
+
}
|
|
40
|
+
export function createFireweavePlugin(options = {}, deps = {}) {
|
|
41
|
+
const env = deps.env ?? process.env;
|
|
42
|
+
const log = deps.log ?? ((line) => console.info(line));
|
|
43
|
+
let skip = false;
|
|
44
|
+
let clientSsr = false;
|
|
45
|
+
return {
|
|
46
|
+
name: 'fireweave',
|
|
47
|
+
enforce: 'pre',
|
|
48
|
+
async config(userConfig, configEnv) {
|
|
49
|
+
if (configEnv.isPreview === true) {
|
|
50
|
+
skip = true;
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (userConfig.build?.lib !== undefined && userConfig.build.lib !== false) {
|
|
54
|
+
skip = true;
|
|
55
|
+
log('[fireweave] build.lib: no config injected. A library must not bake in an app key; the app that bundles it runs fireweave().');
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const envDir = envDirOf(userConfig);
|
|
59
|
+
const loadEnv = deps.loadEnv ?? (envDir === false ? undefined : await viteLoadEnv());
|
|
60
|
+
const files = envDir === false || loadEnv === undefined ? {} : await loadEnv(configEnv.mode, envDir, ENV_PREFIXES);
|
|
61
|
+
const lookup = (name) => sourced(env[name], name) ?? sourced(files[name], `${name} (.env files)`);
|
|
62
|
+
const viteMode = configEnv.command === 'serve' ? sourced(configEnv.mode, `Vite mode '${configEnv.mode}'`) : undefined;
|
|
63
|
+
const resolved = resolveBuild(options, lookup, BUILD_ENV.key, [BUILD_ENV.environment, ENVIRONMENT_FALLBACK], viteMode);
|
|
64
|
+
for (const w of resolved.warnings)
|
|
65
|
+
log(w);
|
|
66
|
+
log(summaryLine(resolved.config));
|
|
67
|
+
return {
|
|
68
|
+
define: { [INJECTED_CONFIG_NAME]: JSON.stringify(resolved.injected) },
|
|
69
|
+
// Keep the SDK out of the dep pre-bundle so the injected config is never cached stale.
|
|
70
|
+
optimizeDeps: { exclude: ['@fireweaveai/web-sdk'] },
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
configResolved(config) {
|
|
74
|
+
if (skip)
|
|
75
|
+
return;
|
|
76
|
+
const prefixes = config.envPrefix === undefined ? ['VITE_'] : typeof config.envPrefix === 'string' ? [config.envPrefix] : [...config.envPrefix];
|
|
77
|
+
const exposed = SERVER_KEY_NAMES.filter((name) => prefixes.some((p) => p !== '' && name.startsWith(p)));
|
|
78
|
+
if (exposed.length > 0) {
|
|
79
|
+
throw new Error(`[fireweave] envPrefix would expose ${exposed.join(' and ')} to the browser bundle. Remove that prefix; the browser key is injected by fireweave() as ${BUILD_ENV.key}.`);
|
|
80
|
+
}
|
|
81
|
+
clientSsr = config.build?.ssr !== undefined && config.build.ssr !== false;
|
|
82
|
+
},
|
|
83
|
+
generateBundle(_options, bundle) {
|
|
84
|
+
if (skip)
|
|
85
|
+
return;
|
|
86
|
+
const serverEnvironment = this.environment?.config?.consumer === 'server' || (this.environment === undefined && clientSsr);
|
|
87
|
+
if (serverEnvironment)
|
|
88
|
+
return;
|
|
89
|
+
const secrets = SERVER_KEY_NAMES.map((name) => env[name]?.trim()).filter((v) => v !== undefined && v.length >= 8);
|
|
90
|
+
for (const [fileName, file] of Object.entries(bundle)) {
|
|
91
|
+
const text = file.type === 'chunk' ? file.code : typeof file.source === 'string' ? file.source : '';
|
|
92
|
+
if (SERVER_KEY_PATTERN.test(text) || secrets.some((secret) => text.includes(secret))) {
|
|
93
|
+
throw new Error(`[fireweave] ${fileName} contains a server key. Server keys must never ship to a browser: remove it from client code, and revoke it if this build was deployed.`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** The fireweave() Vite plugin. Add it to `plugins` in vite.config.ts (or a framework's `vite.plugins`). */
|
|
100
|
+
export function fireweave(options = {}) {
|
|
101
|
+
return createFireweavePlugin(options);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../../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Ae,QAAQ,yIAAyI,CACjK,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,SAAS,CAAC,UAAkC,EAAE;IAC5D,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// GENERATED by tools/release/version.sh apply web — do not edit by hand.
|
|
2
|
+
// The start profile reads SDK_CHANNEL to choose its default fw-server host
|
|
3
|
+
// (docs/adr/0012-start-profile.md). test/unit/start-build-info.test.ts pins
|
|
4
|
+
// SDK_VERSION to package.json, so a release that forgets to stamp fails CI.
|
|
5
|
+
export const SDK_VERSION = '3.0.0-staging.1';
|
|
6
|
+
export const SDK_CHANNEL = 'staging';
|
|
7
|
+
//# sourceMappingURL=build-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-info.js","sourceRoot":"","sources":["../../../../src/start/build-info.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC7C,MAAM,CAAC,MAAM,WAAW,GAA6B,SAAS,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every name the web start profile and its build helpers use, in one place, so
|
|
3
|
+
* the README, the initialise skill and the error messages cannot drift apart.
|
|
4
|
+
*
|
|
5
|
+
* Imported by browser code and by the Node build helpers (node/), so it holds
|
|
6
|
+
* constants only.
|
|
7
|
+
*/
|
|
8
|
+
/** Build-time variables the Vite plugin and the define helper read. The browser reads none. */
|
|
9
|
+
export declare const BUILD_ENV: Readonly<{
|
|
10
|
+
key: "FIREWEAVE_BROWSER_KEY";
|
|
11
|
+
url: "FIREWEAVE_URL";
|
|
12
|
+
environment: "FIREWEAVE_ENV";
|
|
13
|
+
}>;
|
|
14
|
+
/** Fallback environment name after FIREWEAVE_ENV, at build time. */
|
|
15
|
+
export declare const ENVIRONMENT_FALLBACK = "APP_ENV";
|
|
16
|
+
/**
|
|
17
|
+
* Names the scaffolded harness used for the browser key. They held a project
|
|
18
|
+
* (server-family) key, which the start profile refuses, so they are detected
|
|
19
|
+
* only to explain what to set instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RETIRED_KEY_NAMES: readonly string[];
|
|
22
|
+
/** Server secrets the Vite plugin looks for in output chunks. Never injected, never printed. */
|
|
23
|
+
export declare const SERVER_KEY_NAMES: readonly string[];
|
|
24
|
+
/** Environment names that mean "local development" when no key is set. Case-insensitive. */
|
|
25
|
+
export declare const DEV_ENVIRONMENTS: ReadonlySet<string>;
|
|
26
|
+
/** fw-server host for each release channel of this package. */
|
|
27
|
+
export declare const CHANNEL_URLS: Readonly<{
|
|
28
|
+
production: "https://app-server.fireweave.ai";
|
|
29
|
+
staging: "https://staging-app-server.fireweave.ai";
|
|
30
|
+
}>;
|
|
31
|
+
/** Hosts always allowed beside a custom endpoint, so local stacks keep working. */
|
|
32
|
+
export declare const LOOPBACK_HOSTS: readonly string[];
|
|
33
|
+
/** The only key family a browser may hold. */
|
|
34
|
+
export declare const BROWSER_KEY_PREFIX = "fw_public_";
|
|
35
|
+
/** localStorage keys. The device id key and its dev_ prefix match the scaffolded harness, so returning visitors keep their bucket. */
|
|
36
|
+
export declare const STORAGE_KEYS: Readonly<{
|
|
37
|
+
deviceId: "fireweave.device-id";
|
|
38
|
+
identity: "fireweave.identity";
|
|
39
|
+
deviceRegistered: "fireweave.device-registered";
|
|
40
|
+
}>;
|
|
41
|
+
/** Where the control-points object lives by convention; named in warnings. */
|
|
42
|
+
export declare const CONTROL_POINTS_FILE = "src/fireweave/control-points.ts";
|
|
43
|
+
/** The identifier the build helpers define and the browser reads behind a typeof guard. */
|
|
44
|
+
export declare const INJECTED_CONFIG_NAME = "__FIREWEAVE_WEB_CONFIG__";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every name the web start profile and its build helpers use, in one place, so
|
|
3
|
+
* the README, the initialise skill and the error messages cannot drift apart.
|
|
4
|
+
*
|
|
5
|
+
* Imported by browser code and by the Node build helpers (node/), so it holds
|
|
6
|
+
* constants only.
|
|
7
|
+
*/
|
|
8
|
+
/** Build-time variables the Vite plugin and the define helper read. The browser reads none. */
|
|
9
|
+
export const BUILD_ENV = Object.freeze({
|
|
10
|
+
key: 'FIREWEAVE_BROWSER_KEY',
|
|
11
|
+
url: 'FIREWEAVE_URL',
|
|
12
|
+
environment: 'FIREWEAVE_ENV',
|
|
13
|
+
});
|
|
14
|
+
/** Fallback environment name after FIREWEAVE_ENV, at build time. */
|
|
15
|
+
export const ENVIRONMENT_FALLBACK = 'APP_ENV';
|
|
16
|
+
/**
|
|
17
|
+
* Names the scaffolded harness used for the browser key. They held a project
|
|
18
|
+
* (server-family) key, which the start profile refuses, so they are detected
|
|
19
|
+
* only to explain what to set instead.
|
|
20
|
+
*/
|
|
21
|
+
export const RETIRED_KEY_NAMES = Object.freeze(['VITE_FW_PROJECT_API_KEY', 'PUBLIC_FW_PROJECT_API_KEY']);
|
|
22
|
+
/** Server secrets the Vite plugin looks for in output chunks. Never injected, never printed. */
|
|
23
|
+
export const SERVER_KEY_NAMES = Object.freeze(['FIREWEAVE_KEY', 'FW_PROJECT_API_KEY']);
|
|
24
|
+
/** Environment names that mean "local development" when no key is set. Case-insensitive. */
|
|
25
|
+
export const DEV_ENVIRONMENTS = new Set(['development', 'dev', 'local', 'test']);
|
|
26
|
+
/** fw-server host for each release channel of this package. */
|
|
27
|
+
export const CHANNEL_URLS = Object.freeze({
|
|
28
|
+
production: 'https://app-server.fireweave.ai',
|
|
29
|
+
staging: 'https://staging-app-server.fireweave.ai',
|
|
30
|
+
});
|
|
31
|
+
/** Hosts always allowed beside a custom endpoint, so local stacks keep working. */
|
|
32
|
+
export const LOOPBACK_HOSTS = Object.freeze(['localhost', '127.0.0.1', '::1']);
|
|
33
|
+
/** The only key family a browser may hold. */
|
|
34
|
+
export const BROWSER_KEY_PREFIX = 'fw_public_';
|
|
35
|
+
/** localStorage keys. The device id key and its dev_ prefix match the scaffolded harness, so returning visitors keep their bucket. */
|
|
36
|
+
export const STORAGE_KEYS = Object.freeze({
|
|
37
|
+
deviceId: 'fireweave.device-id',
|
|
38
|
+
identity: 'fireweave.identity',
|
|
39
|
+
deviceRegistered: 'fireweave.device-registered',
|
|
40
|
+
});
|
|
41
|
+
/** Where the control-points object lives by convention; named in warnings. */
|
|
42
|
+
export const CONTROL_POINTS_FILE = 'src/fireweave/control-points.ts';
|
|
43
|
+
/** The identifier the build helpers define and the browser reads behind a typeof guard. */
|
|
44
|
+
export const INJECTED_CONFIG_NAME = '__FIREWEAVE_WEB_CONFIG__';
|
|
45
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/start/names.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,eAAe;IACpB,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,yBAAyB,EAAE,2BAA2B,CAAC,CAAC,CAAC;AAE5H,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAE1G,4FAA4F;AAC5F,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtG,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,UAAU,EAAE,iCAAiC;IAC7C,OAAO,EAAE,yCAAyC;CACnD,CAAC,CAAC;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;AAElG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE/C,sIAAsI;AACtI,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,qBAAqB;IAC/B,QAAQ,EAAE,oBAAoB;IAC9B,gBAAgB,EAAE,6BAA6B;CAChD,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;AAErE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type StartMode = 'remote' | 'local';
|
|
2
|
+
export type SdkChannel = 'staging' | 'production';
|
|
3
|
+
/** A value and where it came from ('start({ key })', 'FIREWEAVE_BROWSER_KEY', ...). */
|
|
4
|
+
export interface Sourced {
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly source: string;
|
|
7
|
+
}
|
|
8
|
+
export type PolicyReason = 'invalid-mode' | 'missing-key' | 'server-key' | 'wrong-key-family' | 'insecure-url';
|
|
9
|
+
export interface PolicyInput {
|
|
10
|
+
readonly mode?: unknown;
|
|
11
|
+
readonly key?: Sourced | undefined;
|
|
12
|
+
readonly url?: Sourced | undefined;
|
|
13
|
+
readonly environment?: Sourced | undefined;
|
|
14
|
+
readonly channel: SdkChannel;
|
|
15
|
+
/** The variable or option a fix should name, e.g. FIREWEAVE_BROWSER_KEY. */
|
|
16
|
+
readonly keyVariable: string;
|
|
17
|
+
/** Where an environment name was looked for, for the missing-key message. */
|
|
18
|
+
readonly environmentChecked: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PolicyConfig {
|
|
21
|
+
readonly mode: StartMode;
|
|
22
|
+
/** Why this mode: the mode option, a present key, or the environment name. */
|
|
23
|
+
readonly modeSource: 'option' | 'key' | 'environment';
|
|
24
|
+
/** Remote only. A value starting with '/' is a same-origin proxy path. */
|
|
25
|
+
readonly url?: string;
|
|
26
|
+
readonly urlSource?: string;
|
|
27
|
+
/** Remote only, and absent for the channel default (the core's own list covers it). */
|
|
28
|
+
readonly allowedHosts?: readonly string[];
|
|
29
|
+
/** Remote only. Never logged. */
|
|
30
|
+
readonly key?: string;
|
|
31
|
+
readonly keySource: string;
|
|
32
|
+
readonly environment?: string;
|
|
33
|
+
readonly environmentSource?: string;
|
|
34
|
+
}
|
|
35
|
+
export type PolicyResult = {
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly config: PolicyConfig;
|
|
38
|
+
readonly warnings: readonly string[];
|
|
39
|
+
} | {
|
|
40
|
+
readonly ok: false;
|
|
41
|
+
readonly reason: PolicyReason;
|
|
42
|
+
readonly variable: string;
|
|
43
|
+
readonly message: string;
|
|
44
|
+
};
|
|
45
|
+
/** A trimmed, non-empty string with its source, or undefined. Non-strings count as unset. */
|
|
46
|
+
export declare function sourced(value: unknown, source: string): Sourced | undefined;
|
|
47
|
+
/** The first candidate that is set. */
|
|
48
|
+
export declare function firstOf(...candidates: ReadonlyArray<Sourced | undefined>): Sourced | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve mode, key and endpoint.
|
|
51
|
+
*
|
|
52
|
+
* An explicit mode wins. Otherwise a key means remote; no key and a
|
|
53
|
+
* development environment name means local; anything else fails closed, so a
|
|
54
|
+
* missing key never turns into silent local evaluation for real visitors.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolvePolicy(input: PolicyInput): PolicyResult;
|
|
57
|
+
/**
|
|
58
|
+
* What the build helpers inject as __FIREWEAVE_WEB_CONFIG__: raw values and
|
|
59
|
+
* their source names, re-resolved in the browser so explicit start() options
|
|
60
|
+
* still win. Never carries a server key or the control-points object.
|
|
61
|
+
*/
|
|
62
|
+
export interface InjectedConfig {
|
|
63
|
+
readonly v: 1;
|
|
64
|
+
readonly key?: string;
|
|
65
|
+
readonly keySource?: string;
|
|
66
|
+
readonly url?: string;
|
|
67
|
+
readonly urlSource?: string;
|
|
68
|
+
readonly environment?: string;
|
|
69
|
+
readonly environmentSource?: string;
|
|
70
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web start-profile policy: one pure resolver shared by the browser
|
|
3
|
+
* start() and the Node build helpers (node/vite.ts, node/define.ts), so a
|
|
4
|
+
* build and the page it produces can never disagree about mode, key or URL.
|
|
5
|
+
*
|
|
6
|
+
* Pure on purpose: no DOM, no env, no core import. Callers hand in values
|
|
7
|
+
* with their source names; the result is a config, or a failure carrying a
|
|
8
|
+
* fixed reason code and a message that names sources and variables, never a
|
|
9
|
+
* value.
|
|
10
|
+
*/
|
|
11
|
+
import { BROWSER_KEY_PREFIX, CHANNEL_URLS, DEV_ENVIRONMENTS, LOOPBACK_HOSTS } from './names.js';
|
|
12
|
+
/** A trimmed, non-empty string with its source, or undefined. Non-strings count as unset. */
|
|
13
|
+
export function sourced(value, source) {
|
|
14
|
+
if (typeof value !== 'string')
|
|
15
|
+
return undefined;
|
|
16
|
+
const trimmed = value.trim();
|
|
17
|
+
return trimmed === '' ? undefined : { value: trimmed, source };
|
|
18
|
+
}
|
|
19
|
+
/** The first candidate that is set. */
|
|
20
|
+
export function firstOf(...candidates) {
|
|
21
|
+
return candidates.find((c) => c !== undefined);
|
|
22
|
+
}
|
|
23
|
+
const fail = (reason, variable, message) => ({
|
|
24
|
+
ok: false,
|
|
25
|
+
reason,
|
|
26
|
+
variable,
|
|
27
|
+
message: `[fireweave] ${message}`,
|
|
28
|
+
});
|
|
29
|
+
/** Key family check. Messages name the source, never the value. */
|
|
30
|
+
function checkKey(key) {
|
|
31
|
+
const v = key.value;
|
|
32
|
+
if (v.startsWith(BROWSER_KEY_PREFIX))
|
|
33
|
+
return undefined;
|
|
34
|
+
if (v.startsWith('project-api-key_')) {
|
|
35
|
+
return fail('server-key', key.source, `The key from ${key.source} is a server key (project-api-key_…), which must never ship to a browser. Use a browser key (fw_public_…) from Project settings, API keys. If a bundle built with this key was deployed, revoke the key.`);
|
|
36
|
+
}
|
|
37
|
+
if (/^ph[a-z]_/.test(v)) {
|
|
38
|
+
return fail('wrong-key-family', key.source, `The key from ${key.source} is an analytics vendor key, not a FireWeave browser key (fw_public_…).`);
|
|
39
|
+
}
|
|
40
|
+
if (v.startsWith('fw_org_') || v.startsWith('cli_at_')) {
|
|
41
|
+
return fail('wrong-key-family', key.source, `The key from ${key.source} is an organisation or CLI token, not a FireWeave browser key (fw_public_…).`);
|
|
42
|
+
}
|
|
43
|
+
return fail('wrong-key-family', key.source, `The key from ${key.source} is not a FireWeave browser key (fw_public_…).`);
|
|
44
|
+
}
|
|
45
|
+
const isLoopback = (hostname) => hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1' || hostname === '[::1]';
|
|
46
|
+
function resolveUrl(url, channel) {
|
|
47
|
+
if (url === undefined)
|
|
48
|
+
return { url: CHANNEL_URLS[channel], urlSource: `SDK channel (${channel})` };
|
|
49
|
+
const value = url.value.replace(/\/+$/, '');
|
|
50
|
+
if (value.startsWith('//')) {
|
|
51
|
+
return fail('insecure-url', url.source, `The endpoint from ${url.source} is protocol-relative. Use an https URL or a same-origin path such as '/fw'.`);
|
|
52
|
+
}
|
|
53
|
+
// A same-origin proxy path: the browser resolves it against location.origin.
|
|
54
|
+
if (value.startsWith('/'))
|
|
55
|
+
return { url: value, urlSource: url.source };
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = new URL(value);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return fail('insecure-url', url.source, `The endpoint from ${url.source} is not a valid URL.`);
|
|
62
|
+
}
|
|
63
|
+
const httpsOk = parsed.protocol === 'https:';
|
|
64
|
+
const loopbackHttp = parsed.protocol === 'http:' && isLoopback(parsed.hostname);
|
|
65
|
+
if (!httpsOk && !loopbackHttp) {
|
|
66
|
+
return fail('insecure-url', url.source, `The endpoint from ${url.source} must use https (http is allowed only for localhost).`);
|
|
67
|
+
}
|
|
68
|
+
return { url: value, urlSource: url.source, allowedHosts: [parsed.hostname.replace(/^\[|\]$/g, ''), ...LOOPBACK_HOSTS] };
|
|
69
|
+
}
|
|
70
|
+
function remote(input, key, modeSource, warnings) {
|
|
71
|
+
const keyProblem = checkKey(key);
|
|
72
|
+
if (keyProblem !== undefined)
|
|
73
|
+
return keyProblem;
|
|
74
|
+
const url = resolveUrl(input.url, input.channel);
|
|
75
|
+
if ('ok' in url)
|
|
76
|
+
return url;
|
|
77
|
+
return { ok: true, config: { mode: 'remote', modeSource, ...url, key: key.value, keySource: key.source }, warnings };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve mode, key and endpoint.
|
|
81
|
+
*
|
|
82
|
+
* An explicit mode wins. Otherwise a key means remote; no key and a
|
|
83
|
+
* development environment name means local; anything else fails closed, so a
|
|
84
|
+
* missing key never turns into silent local evaluation for real visitors.
|
|
85
|
+
*/
|
|
86
|
+
export function resolvePolicy(input) {
|
|
87
|
+
const warnings = [];
|
|
88
|
+
const { mode, key, environment } = input;
|
|
89
|
+
if (mode !== undefined && mode !== 'remote' && mode !== 'local') {
|
|
90
|
+
return fail('invalid-mode', 'mode', `start({ mode }) must be 'remote' or 'local'.`);
|
|
91
|
+
}
|
|
92
|
+
if (mode === 'local') {
|
|
93
|
+
if (key !== undefined) {
|
|
94
|
+
warnings.push(`[fireweave] mode 'local' ignores the key from ${key.source}; nothing is sent to fw-server.`);
|
|
95
|
+
}
|
|
96
|
+
return { ok: true, config: { mode: 'local', modeSource: 'option', keySource: 'none' }, warnings };
|
|
97
|
+
}
|
|
98
|
+
if (mode === 'remote') {
|
|
99
|
+
if (key === undefined) {
|
|
100
|
+
return fail('missing-key', input.keyVariable, `mode 'remote' needs a browser key. Set ${input.keyVariable} to a browser key (fw_public_…).`);
|
|
101
|
+
}
|
|
102
|
+
return remote(input, key, 'option', warnings);
|
|
103
|
+
}
|
|
104
|
+
if (key !== undefined)
|
|
105
|
+
return remote(input, key, 'key', warnings);
|
|
106
|
+
if (environment !== undefined && DEV_ENVIRONMENTS.has(environment.value.toLowerCase())) {
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
config: {
|
|
110
|
+
mode: 'local',
|
|
111
|
+
modeSource: 'environment',
|
|
112
|
+
keySource: 'none',
|
|
113
|
+
environment: environment.value,
|
|
114
|
+
environmentSource: environment.source,
|
|
115
|
+
},
|
|
116
|
+
warnings,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const where = environment === undefined
|
|
120
|
+
? `no environment name is set (checked ${input.environmentChecked})`
|
|
121
|
+
: `the environment is '${environment.value}' (from ${environment.source}), which is not a development name`;
|
|
122
|
+
return fail('missing-key', input.keyVariable, `${input.keyVariable} is not set and ${where}. Set ${input.keyVariable} to a browser key (fw_public_…), or for local work set FIREWEAVE_ENV=development or pass start({ mode: 'local' }).`);
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../../src/start/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA6ChG,6FAA6F;AAC7F,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,MAAc;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;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W,CAAC,MAAM;aACtC;YACD,QAAQ;SACT,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GACT,WAAW,KAAK,SAAS;QACvB,CAAC,CAAC,uCAAuC,KAAK,CAAC,kBAAkB,GAAG;QACpE,CAAC,CAAC,uBAAuB,WAAW,CAAC,KAAK,WAAW,WAAW,CAAC,MAAM,oCAAoC,CAAC;IAChH,OAAO,IAAI,CACT,aAAa,EACb,KAAK,CAAC,WAAW,EACjB,GAAG,KAAK,CAAC,WAAW,mBAAmB,KAAK,SAAS,KAAK,CAAC,WAAW,oHAAoH,CAC3L,CAAC;AACJ,CAAC"}
|
package/dist/domain/errors.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* on a machine we do not control, so nothing host-, key-, or response-derived
|
|
12
12
|
* is ever interpolated into one.
|
|
13
13
|
*/
|
|
14
|
-
export type FireweaveErrorKind = 'Configuration' | 'Authentication' | 'Authorization' | 'Network' | 'Timeout' | 'RateLimited' | 'BackendUnavailable' | 'MalformedResponse' | 'InvalidContext' | '
|
|
14
|
+
export type FireweaveErrorKind = 'Configuration' | 'Authentication' | 'Authorization' | 'Network' | 'Timeout' | 'RateLimited' | 'BackendUnavailable' | 'MalformedResponse' | 'InvalidContext' | 'ControlPointNotFound' | 'TypeMismatch' | 'NotReady' | 'AlreadyClosed' | 'UnsupportedCapability' | 'Internal';
|
|
15
15
|
export type OpenFeatureErrorCode = 'PROVIDER_NOT_READY' | 'PROVIDER_FATAL' | 'FLAG_NOT_FOUND' | 'PARSE_ERROR' | 'TYPE_MISMATCH' | 'TARGETING_KEY_MISSING' | 'INVALID_CONTEXT' | 'GENERAL';
|
|
16
16
|
export interface ErrorKindSpec {
|
|
17
17
|
readonly message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/domain/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,kBAAkB,GA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