@configdirector/nuxt-sdk 0.9.0 → 0.9.2

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/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "0.9.0"
7
+ "version": "0.9.2"
8
8
  }
@@ -1390,6 +1390,7 @@ var DefaultConfigDirectorClient = class {
1390
1390
  this.logger = clientOptions?.logger ?? createDefaultLogger$1();
1391
1391
  this.timeout = clientOptions?.connection?.timeout ?? 3e3;
1392
1392
  this.metaContext = clientOptions?.metadata ?? {};
1393
+ this.validateSdkKeyPresence(serverSdkKey);
1393
1394
  this.configEvaluator = new ConfigEvaluator(this.logger);
1394
1395
  const baseUrl = this.parseUrl(clientOptions?.connection?.url) ?? defaultBaseUrl;
1395
1396
  this.connectionMode = clientOptions?.connection?.mode ?? "streaming";
@@ -1574,6 +1575,9 @@ var DefaultConfigDirectorClient = class {
1574
1575
  throw new ConfigDirectorValidationError(`Invalid base URL '${url}'. Parsing failed: ${error}`);
1575
1576
  }
1576
1577
  }
1578
+ validateSdkKeyPresence(sdkKey) {
1579
+ if (!sdkKey || sdkKey.trim().length == 0) throw new ConfigDirectorValidationError("No server SDK key was provided, the client cannot be instantiated without a valid server SDK key");
1580
+ }
1577
1581
  validateDefaultValue(defaultValue) {
1578
1582
  if (defaultValue === void 0 || defaultValue === null) throw new ConfigDirectorValidationError("Invalid default value. The default value for a config must be defined and non-null.");
1579
1583
  if (typeof defaultValue === "function") throw new ConfigDirectorValidationError("Invalid default value. The default value for a config cannot be a function.");
@@ -1636,7 +1640,7 @@ var plugin_default = defineNitroPlugin((nitroApp) => {
1636
1640
  const { serverSdkKey, baseUrl } = runtimeConfig.configdirector;
1637
1641
  const client = new DefaultConfigDirectorClient(serverSdkKey, {
1638
1642
  sdkName: "nuxt-sdk",
1639
- sdkVersion: "0.9.0"
1643
+ sdkVersion: "0.9.2"
1640
1644
  }, {
1641
1645
  logger,
1642
1646
  ...baseUrl ? { connection: { url: baseUrl } } : {}
@@ -818,6 +818,15 @@ const parseUrl = (url) => {
818
818
  }
819
819
  };
820
820
  //#endregion
821
+ //#region ../shared/src/instance-id.ts
822
+ const generateInstanceId = () => {
823
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
824
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (placeholder) => {
825
+ const random = Math.random() * 16 | 0;
826
+ return (placeholder === "x" ? random : random & 3 | 8).toString(16);
827
+ });
828
+ };
829
+ //#endregion
821
830
  //#region ../js-client-core/src/DefaultConfigDirectorClient.ts
822
831
  const MAX_EXPONENTIAL_DELAY = 9;
823
832
  var DefaultConfigDirectorClient = class {
@@ -837,9 +846,10 @@ var DefaultConfigDirectorClient = class {
837
846
  connectionMode;
838
847
  instanceId;
839
848
  constructor(telemetryClient, clientSdkKey, sdkOptions, clientOptions, internalClientOptions) {
840
- this.instanceId = crypto.randomUUID();
849
+ this.instanceId = generateInstanceId();
841
850
  this.logger = clientOptions?.logger ?? createDefaultLogger$1();
842
851
  this.timeout = clientOptions?.connection?.timeout ?? 3e3;
852
+ this.validateSdkKeyPresence(clientSdkKey);
843
853
  const urlFactory = internalClientOptions?.urlFactory ?? defaultUrlFactory;
844
854
  const baseUrl = this.parseUrl(clientOptions?.connection?.url, urlFactory) ?? "https://client-sdk-api.configdirector.com";
845
855
  this.connectionMode = clientOptions?.connection?.mode ?? "streaming";
@@ -1032,6 +1042,9 @@ var DefaultConfigDirectorClient = class {
1032
1042
  throw new ConfigDirectorValidationError(`Invalid base URL '${url}'. Parsing failed: ${error}`);
1033
1043
  }
1034
1044
  }
1045
+ validateSdkKeyPresence(sdkKey) {
1046
+ if (!sdkKey || sdkKey.trim().length == 0) throw new ConfigDirectorValidationError("No client SDK key was provided, the client cannot be instantiated without a valid client SDK key");
1047
+ }
1035
1048
  validateDefaultValue(defaultValue) {
1036
1049
  if (defaultValue === void 0 || defaultValue === null) throw new ConfigDirectorValidationError("Invalid default value. The default value for a config must be defined and non-null.");
1037
1050
  if (typeof defaultValue === "function") throw new ConfigDirectorValidationError("Invalid default value. The default value for a config cannot be a function.");
@@ -1295,7 +1308,7 @@ var plugin_client_default = defineNuxtPlugin((nuxtApp) => {
1295
1308
  const { clientSdkKey, appName, appVersion, baseUrl } = runtimeConfig.public.configdirector;
1296
1309
  const client = createBrowserClient(clientSdkKey, {
1297
1310
  sdkName: "nuxt-sdk",
1298
- sdkVersion: "0.9.0"
1311
+ sdkVersion: "0.9.2"
1299
1312
  }, {
1300
1313
  metadata: {
1301
1314
  appName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configdirector/nuxt-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Nuxt SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.",
5
5
  "license": "MIT",
6
6
  "author": "ConfigDirector",
@@ -62,7 +62,7 @@
62
62
  "@nuxt/test-utils": "^4.0.2",
63
63
  "@types/node": "latest",
64
64
  "changelogen": "^0.6.2",
65
- "eslint": "^10.2.1",
65
+ "eslint": "^10.7.0",
66
66
  "nuxt": "^4.4.8",
67
67
  "playwright": "^1.60.0",
68
68
  "rimraf": "^6.1.3",