@lunora/flags 1.0.0-alpha.44 → 1.0.0-alpha.46

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.
@@ -1 +1 @@
1
- import{FlagshipServerProvider as d}from"@cloudflare/flagship/server";import{LunoraError as o}from"@lunora/errors";const p=e=>"binding"in e&&typeof e.binding=="string",h=e=>{if(p(e)){const{binding:n,...i}=e;return u=>{const t=u[n];if(t==null)throw new o("INTERNAL",`flagshipProvider: no binding "${n}" found on env. Add a \`flagship\` binding to wrangler.jsonc, e.g. { "flagship": [{ "binding": "${n}", "app_id": "your-app-id" }] }.`);return new d({binding:t,...i})}}const{appId:a,endpoint:s}=e;if(a===void 0&&s===void 0)throw new o("INTERNAL",'flagshipProvider: HTTP mode requires either `appId` (the SDK builds the evaluation URL) or `endpoint` (a full evaluation URL). Pass exactly one, or use binding mode: `flagshipProvider({ binding: "FLAGS" })`.');if(a!==void 0&&s!==void 0)throw new o("INTERNAL","flagshipProvider: `appId` and `endpoint` are mutually exclusive in HTTP mode — pass exactly one.");const{authToken:r,...l}=e;return n=>{if(typeof r!="function")return new d({...l,...r===void 0?{}:{authToken:r}});const i=r(n);if(typeof i!="string"||i.length===0)throw new o("INTERNAL","flagshipProvider: `authToken` resolved to an empty or non-string value — check that the env var the thunk reads is set. An unset secret would send `Bearer undefined`, and every evaluation would silently fall back to its default.");return new d({...l,authToken:i})}};export{h as flagshipProvider};
1
+ import{FlagshipServerProvider as a}from"@cloudflare/flagship/server";import{LunoraError as r}from"@lunora/errors";const h=e=>"binding"in e&&typeof e.binding=="string",g=e=>{if(h(e)){const{binding:n,...i}=e;return l=>{const o=l[n];if(o==null)throw new r("INTERNAL",`flagshipProvider: no binding "${n}" found on env. Add a \`flagship\` binding to wrangler.jsonc, e.g. { "flagship": [{ "binding": "${n}", "app_id": "your-app-id" }] }.`);return new a({binding:o,...i})}}const{appId:d,endpoint:s}=e;if(d===void 0&&s===void 0)throw new r("INTERNAL",'flagshipProvider: HTTP mode requires either `appId` (the SDK builds the evaluation URL) or `endpoint` (a full evaluation URL). Pass exactly one, or use binding mode: `flagshipProvider({ binding: "FLAGS" })`.');if(d!==void 0&&s!==void 0)throw new r("INTERNAL","flagshipProvider: `appId` and `endpoint` are mutually exclusive in HTTP mode — pass exactly one.");if(e.authToken==="")throw new r("INTERNAL","flagshipProvider: `authToken` is an empty string — omit it for an unauthenticated endpoint, or pass a thunk so the secret is read off the Worker env at request time.");const{authToken:t,...u}=e;return n=>{if(typeof t!="function")return new a({...u,...t===void 0?{}:{authToken:t}});const i=t(n);if(typeof i!="string"||i.length===0)throw new r("INTERNAL","flagshipProvider: `authToken` resolved to an empty or non-string value — check that the env var the thunk reads is set. An unset secret would send `Bearer undefined`, and every evaluation would silently fall back to its default.");return new a({...u,authToken:i})}};export{g as flagshipProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/flags",
3
- "version": "1.0.0-alpha.44",
3
+ "version": "1.0.0-alpha.46",
4
4
  "description": "OpenFeature-based feature flags for Lunora — ctx.flags, useFlag, and a first-class Cloudflare Flagship provider with any OpenFeature provider pluggable",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -60,7 +60,7 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "@lunora/errors": "1.0.0-alpha.31",
63
+ "@lunora/errors": "1.0.0-alpha.32",
64
64
  "@openfeature/server-sdk": "^1.23.0"
65
65
  },
66
66
  "peerDependencies": {