@npaw/forge-web 9.6.1 → 9.7.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.
Binary file
package/dist/index.cjs CHANGED
@@ -3096,6 +3096,52 @@ function currentHref2() {
3096
3096
  return (_b = (_a = globalLocation()) == null ? void 0 : _a.href) != null ? _b : "https://localhost/";
3097
3097
  }
3098
3098
 
3099
+ // src/device-identity.ts
3100
+ var DEVICE_UUID_STORAGE_KEY = "npawForgeDeviceUUID";
3101
+ function persistentDeviceUuid() {
3102
+ var _a;
3103
+ const stored = readStoredUuid();
3104
+ if (stored) {
3105
+ return stored;
3106
+ }
3107
+ const generated = randomUuid();
3108
+ try {
3109
+ (_a = globalThis.localStorage) == null ? void 0 : _a.setItem(DEVICE_UUID_STORAGE_KEY, generated);
3110
+ } catch (e) {
3111
+ }
3112
+ return generated;
3113
+ }
3114
+ function readStoredUuid() {
3115
+ var _a;
3116
+ try {
3117
+ const value = (_a = globalThis.localStorage) == null ? void 0 : _a.getItem(DEVICE_UUID_STORAGE_KEY);
3118
+ return value && value.trim().length > 0 ? value : void 0;
3119
+ } catch (e) {
3120
+ return void 0;
3121
+ }
3122
+ }
3123
+ function randomUuid() {
3124
+ const cryptoRef = globalThis.crypto;
3125
+ if (typeof (cryptoRef == null ? void 0 : cryptoRef.randomUUID) === "function") {
3126
+ return cryptoRef.randomUUID();
3127
+ }
3128
+ if (typeof (cryptoRef == null ? void 0 : cryptoRef.getRandomValues) === "function") {
3129
+ const bytes = cryptoRef.getRandomValues(new Uint8Array(16));
3130
+ bytes[6] = bytes[6] & 15 | 64;
3131
+ bytes[8] = bytes[8] & 63 | 128;
3132
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
3133
+ return [
3134
+ hex.slice(0, 8),
3135
+ hex.slice(8, 12),
3136
+ hex.slice(12, 16),
3137
+ hex.slice(16, 20),
3138
+ hex.slice(20, 32)
3139
+ ].join("-");
3140
+ }
3141
+ const random = () => Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
3142
+ return `${random()}-${random().slice(0, 4)}-4${random().slice(0, 3)}-a${random().slice(0, 3)}-${random()}${random().slice(0, 4)}`;
3143
+ }
3144
+
3099
3145
  // src/utils.ts
3100
3146
  function systemClock() {
3101
3147
  return {
@@ -3863,6 +3909,7 @@ function isEffectCompletion(command) {
3863
3909
  return command.type === "httpCompleted" || command.type === "httpFailed" || command.type === "storageReadCompleted" || command.type === "storageWriteCompleted" || command.type === "storageDeleteCompleted";
3864
3910
  }
3865
3911
  function runtimeConfig(options) {
3912
+ var _a, _b;
3866
3913
  const config = {
3867
3914
  accountCode: options.accountCode
3868
3915
  };
@@ -3885,6 +3932,13 @@ function runtimeConfig(options) {
3885
3932
  options.preSessionEventQueueMaxAgeMs
3886
3933
  );
3887
3934
  assignOptional(config, "logLevel", options.logLevel);
3935
+ const autoDeviceIdentity = (_a = options.autoDeviceIdentity) != null ? _a : true;
3936
+ assignOptional(
3937
+ config,
3938
+ "deviceUuid",
3939
+ (_b = options.deviceUuid) != null ? _b : autoDeviceIdentity ? persistentDeviceUuid() : void 0
3940
+ );
3941
+ assignOptional(config, "deviceInfo", options.deviceInfo);
3888
3942
  return config;
3889
3943
  }
3890
3944
  function assignOptional(config, key, value) {